26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
52 #pragma package(smart_init)
62 TTrain::TTrain(
int Caller,
int RearStartElementIn,
int RearStartExitPosIn, AnsiString InputCode,
int StartSpeedIn,
int MassIn,
double MaxRunningSpeedIn,
63 double MaxBrakeRateIn,
double PowerAtRailIn,
TTrainMode TrainModeIn,
TTrainDataEntry *TrainDataEntryPtrIn,
int RepeatNumberIn,
int IncrementalMinutesIn,
64 int IncrementalDigitsIn,
int SignallerMaxSpeedIn) : RearStartElement(RearStartElementIn), RearStartExitPos(RearStartExitPosIn), HeadCode(InputCode),
65 StartSpeed(StartSpeedIn), Mass(MassIn), MaxRunningSpeed(MaxRunningSpeedIn), MaxBrakeRate(MaxBrakeRateIn), PowerAtRail(PowerAtRailIn),
66 TrainMode(TrainModeIn), TrainDataEntryPtr(TrainDataEntryPtrIn), RepeatNumber(RepeatNumberIn), IncrementalMinutes(IncrementalMinutesIn),
67 IncrementalDigits(IncrementalDigitsIn), SignallerMaxSpeed(SignallerMaxSpeedIn)
78 AnsiString(RearStartExitPosIn) +
"," + AnsiString(InputCode) +
"," + AnsiString(StartSpeedIn) +
"," + AnsiString(MassIn) +
"," +
79 AnsiString(TrainModeIn));
123 for(
int x = 0; x < 4; x++)
132 for(
int x = 0; x < 4; x++)
141 for(
int x = 0; x < 4; x++)
146 for(
int x = 0; x < 4; x++)
150 for(
int x = 0; x < 3; x++)
187 for(
int x = 0; x < 4; x++)
234 throw Exception(
"Error in attempting to delete FrontCodePtr");
238 for(
int x = 0; x < 4; x++)
242 throw Exception(
"Error in attempting to delete BackgroundPtr[" + AnsiString(x) +
"]");
247 for(
int x = 0; x < 4; x++)
251 throw Exception(
"Error in attempting to delete HeadCodeGrPtr[" + AnsiString(x) +
"]");
280 int NextElementPosition, NextEntryPos, ElementLength, SpeedLimit;
346 bool TempDerail =
false;
392 else if((NextElementPosition > -1) && (NextEntryPos > -1))
463 throw Exception(
"Error, LeadElement Exit Connection is NotSet");
473 for(
int x = 0; x < 4; x++)
480 for(
int x = 0; x < 4; x++)
723 if((random(RandRange)) == 0)
738 int LockedVectorNumber;
975 if(BufferLocation ==
"")
980 if((BufferLocation ==
"") || (BufferLocation != ExpectedLocation))
1042 int NextElementPosition, NextEntryPos;
1066 NextElementPosition = -1;
1069 if((NextElementPosition > -1) && (NextEntryPos > -1))
1183 AnsiString StationName;
1194 throw Exception(
"Error - Stopped at through station but neither lead nor mid elements have a name");
1207 if((NextElementPosition > -1) && (NextEntryPos > -1))
1330 if(NextElementPosition > -1)
1367 AnsiString Loc =
"";
1368 bool LocNamed =
false;
1397 Loc =
"outside railway";
1429 NextElementPosition = -1;
1440 if((NextElementPosition > -1) && (NextEntryPos > -1) && !
SPADFlag)
1458 if((NextElementPosition > -1) && (NextEntryPos > -1))
1496 FirstPair.second).
GetELink() == TempELink))
1501 SecondPair.second).
GetELink() == TempELink))
1515 FirstPair.second).
GetELink() == TempELink))
1520 SecondPair.second).
GetELink() == TempELink))
1534 FirstPair.second).
GetELink() == TempELink))
1539 SecondPair.second).
GetELink() == TempELink))
1569 ContinuationAutoSigEntry.
RouteNumber = RouteNumber;
1572 int NewLastElement = 0, NewLastExitPos = 0;
1590 if(NewLastElement == -1)
1593 throw Exception(
"Error, Connection = -1 in Continuation loop in UpdateTrain");
1596 if(NewLastExitPos == -1)
1598 throw Exception(
"Error, ConnLinkPos = -1 in Continuation loop in UpdateTrain");
1600 LastElement = NewLastElement;
1601 LastExitPos = NewLastExitPos;
1604 if(CumDistance < 1200)
1610 int FirstDistance = 0;
1611 if(CumDistance >= 1200)
1613 FirstDistance = 100;
1617 FirstDistance = 1200 - CumDistance;
1619 if(FirstDistance < 100)
1621 FirstDistance = 100;
1647 if(VectorIT->RouteNumber == RouteNumber)
1694 LockedVectorNumber)))
1853 for(
int x = 0; x < 4; x++)
1860 for(
int x = 0; x < 4; x++)
1886 if((LeadElementTrainID > -1) && (LeadElementTrainID !=
TrainID))
1891 if(OtherTrainEntryPos == -1)
1893 throw Exception(
"Error - OtherTrainEntryPos not set");
1912 int OtherTrainID = -1;
1913 if((MidExitLinkNum == 1) || (MidExitLinkNum == 3) || (MidExitLinkNum == 7) || (MidExitLinkNum == 9))
2004 bool StopRequired =
false;
2017 int NextElementEntryPos = -1;
2018 int NextElementExitPos = -1;
2019 bool TrainOnNextElement =
false;
2020 bool StopSignalAtNextElement =
false;
2021 if(ForwardConnection)
2029 StopSignalAtNextElement = ((NextTrackElement.
Config[NextElementExitPos] ==
Signal) && (NextTrackElement.
Attribute == 0));
2032 if(TrainAtStopLinkPos1 || TrainAtStopLinkPos2 || (ForwardConnection && (TrainOnNextElement || StopSignalAtNextElement)))
2087 throw Exception(
"Error, Straddle shouldn't be LeadMid prior to resetting at exit from UpdateTrain");
2300 if(Code.Length() != 4)
2304 for(
int x = 1; x < 5; x++)
2311 for(
int x = 0; x < 4; x++)
2475 throw Exception(
"Error in GetOffsetValues - Link value wrong");
2488 if((EntryLink == 1) || (EntryLink == 2) || (EntryLink == 4) || (EntryLink == 7))
2503 AnsiString(
VOffset) +
"," + AnsiString(Element) +
"," + AnsiString(EntryPos) +
"," +
HeadCode);
2512 TRect SourceRect, DestRect;
2514 DestRect.init(0, 0, 8, 8);
2517 Graphics::TBitmap *TempGraphic =
new Graphics::TBitmap;
2519 TempGraphic->PixelFormat = pf8bit;
2520 TempGraphic->Width = 16;
2521 TempGraphic->Height = 16;
2527 TempGraphic->Transparent =
true;
2531 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2532 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2538 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2546 else if(TempElement.
SpeedTag == 89)
2550 else if(TempElement.
SpeedTag == 90)
2554 else if(TempElement.
SpeedTag == 91)
2558 else if(TempElement.
SpeedTag == 92)
2562 else if(TempElement.
SpeedTag == 93)
2566 else if(TempElement.
SpeedTag == 94)
2570 else if(TempElement.
SpeedTag == 95)
2574 TempGraphic->Transparent =
true;
2578 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2579 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2581 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2588 for(
int x = 0; x < 40; x++)
2603 TempGraphic->Transparent =
true;
2607 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2608 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2610 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2624 TempGraphic->Transparent =
true;
2628 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2629 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2633 TempGraphic->Canvas->Draw(0, 0, TempElement.
GraphicPtr);
2636 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2641 TempGraphic->Transparent =
true;
2645 int BDVectorPos = -1;
2654 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2659 TempGraphic->Transparent =
true;
2663 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2664 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2666 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2672 TempGraphic->Transparent =
true;
2676 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2677 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2679 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2945 throw Exception(
"Error, same train on two different bridge tracks");
2991 AnsiString(EntryPos) +
"," +
HeadCode);
3008 throw Exception(
"Error, TrackVectorPosition set but not EntryPos in SetTrainElementID");
3027 AnsiString(EntryPos) +
"," +
HeadCode);
3036 throw Exception(
"Error, TrackVectorPosition set but not EntryPos in ResetTrainElementID");
3069 AnsiString(ElementEntryPos) +
"," + AnsiString(
HOffset) +
"," + AnsiString(
VOffset) +
"," + AnsiString(StraddleValue) +
"," +
HeadCode);
3070 int LockedVectorNumber;
3083 TRect SourceRect, DestRect;
3084 DestRect.init(0, 0, 8, 8);
3091 int FirstELink, SecondELink = -1;
3094 if(RoutePair2.first > -1)
3103 if(SecondELink == -1)
3105 throw Exception(
"Error - Second ELink should be set but isn't in PlotAlternativeTrackRouteGraphic [1]");
3110 throw Exception(
"Error - First & Second ELinks have same value in PlotAlternativeTrackRouteGraphic");
3120 Graphics::TBitmap *DestGraphic =
new Graphics::TBitmap;
3121 DestGraphic->PixelFormat = pf8bit;
3122 DestGraphic->Width = 8;
3123 DestGraphic->Height = 8;
3124 DestGraphic->Transparent =
true;
3127 DestGraphic->Canvas->CopyRect(DestRect, RouteElement.
GetRouteEXGraphicPtr()->Canvas, SourceRect);
3136 PrefDirElement, LockedVectorNumber))
3151 if(ElementEntryPos > 1)
3173 AnsiString(EntryPos) +
"," +
HeadCode);
3175 bool WrongRoute =
false;
3201 int LinkNumber = TrackElement.
Link[EntryPos];
3202 if((LinkNumber == 1) || (LinkNumber == 3) || (LinkNumber == 7) || (LinkNumber == 9))
3207 bool LogActionErrorCalled =
false;
3217 LogActionErrorCalled =
true;
3234 else if(LinkNumber == 3)
3242 LogActionErrorCalled =
true;
3259 else if(LinkNumber == 7)
3267 LogActionErrorCalled =
true;
3284 else if(LinkNumber == 9)
3292 LogActionErrorCalled =
true;
3324 else if((RouteElement.
GetELinkPos() == 2) && (EntryPos == 0) && PointsAtElement)
3329 else if((RouteElement.
GetELinkPos() == 0) && (EntryPos == 2) && PointsAtElement)
3339 else if((RouteElement.
GetXLinkPos() == 2) && (EntryPos == 0) && PointsAtElement)
3344 else if((RouteElement.
GetXLinkPos() == 0) && (EntryPos == 2) && PointsAtElement)
3353 throw Exception(
"Error, Element in route but no route found in CheckAndCancelRouteForWrongEndEntry");
3374 bool ColourError =
false, ColourError2 =
false;
3379 ColourError2 =
true;
3381 for(
int x = 0; x < 4; x++)
3386 ColourError2 =
true;
3392 "ERROR: Colour depth insufficient to display train colours properly. Please ensure that the 'safe' (web) palette of 256 colours can be displayed");
3396 for(
int x = 0; x < 4; x++)
3483 AnsiString(EntryPos) +
"," +
HeadCode);
3484 int EntryHalfLength, CurrentElementHalfLength, NextElementHalfLength, CumulativeLength = 0, CurrentTrackVectorPosition = TrackVectorPosition;
3485 int DistanceAtHalfBraking, DistanceAtThreeQuarterBraking, ExitPos, NextTrackVectorPosition, NextEntryPos;
3486 bool RedSignalFlag =
false, BuffersFlag =
false, StationFlag =
false, BuffersOrContinuationNowFlag =
false, ContinuationNextFlag =
false,
3487 TrainInFrontInSignallerModeFlag =
false;
3488 double LimitingSpeed, FrontElementMaxSpeed, MaxExitSpeedAtHalfBrakingSquared, MaxExitSpeedAtHalfBraking, NextSpeedLimit, TempBrakeRate;
3489 double ExitSpeedHalfSquared, ExitSpeedFullSquared;
3490 bool SignallerStopRequired =
false;
3501 if(CurrentTrackVectorPosition > -1)
3505 if((EntryPos == 0) || (EntryPos == 2))
3518 else if(EntryPos == 1)
3542 EntryHalfLength = CurrentElementHalfLength;
3547 throw Exception(
"Error - CurrentTrackVectorPosition < 0 in SetTrainMovementValues");
3551 throw Exception(
"Error - HalfLength or SpeedLimit < 0 in SetTrainMovementValues");
3598 FrontElementMaxSpeed = LimitingSpeed;
3628 double ExitSpeedAtMaxBraking;
3633 ExitSpeedAtMaxBraking = 0;
3643 if(ExitSpeedAtMaxBraking > LimitingSpeed)
3645 SpeedToUse = ExitSpeedAtMaxBraking;
3649 SpeedToUse = LimitingSpeed;
3664 RedSignalFlag =
false;
3665 BuffersFlag =
false;
3666 StationFlag =
false;
3667 BuffersOrContinuationNowFlag =
false;
3668 ContinuationNextFlag =
false;
3671 CumulativeLength += (2 * CurrentElementHalfLength);
3674 SignallerStopRequired =
true;
3696 bool StopRequired =
false;
3710 StationFlag =
false;
3716 BuffersOrContinuationNowFlag =
true;
3718 if(!BuffersOrContinuationNowFlag && !BuffersFlag && !StationFlag)
3722 if((EntryPos == 0) || (EntryPos == 2))
3744 if(NextTrackVectorPosition > -1)
3749 if((NextEntryPos == 0) || (NextEntryPos == 2))
3762 else if(NextEntryPos == 1)
3775 if(NextEntryPos > 1)
3789 throw Exception(
"Error - Trying to access NextTrackVectorPosition when none present in SetTrainMovementValues");
3801 RedSignalFlag =
true;
3823 TrainInFrontInSignallerModeFlag =
true;
3847 if(RedSignalFlag || BuffersFlag || StationFlag || TrainInFrontInSignallerModeFlag || SignallerStopRequired ||
StepForwardFlag)
3859 double MaxHalfSpeed;
3863 if(MaxHalfSpeedAtHalfBraking > FrontElementMaxSpeed)
3865 MaxHalfSpeed = FrontElementMaxSpeed;
3869 MaxHalfSpeed = MaxHalfSpeedAtHalfBraking;
3877 bool HalfSpeedLimited =
false;
3881 HalfSpeedLimited =
true;
3911 if(HalfSpeedLimited)
3936 if(SignallerStopRequired)
3952 int TempMaxExitSpeed;
3955 if(MaxExitSpeedAtHalfBrakingSquared < 10)
3957 MaxExitSpeedAtHalfBraking = 0;
3961 MaxExitSpeedAtHalfBraking = sqrt(MaxExitSpeedAtHalfBrakingSquared);
3965 if(MaxExitSpeedAtHalfBraking > FrontElementMaxSpeed)
3967 TempMaxExitSpeed = FrontElementMaxSpeed;
3971 TempMaxExitSpeed = MaxExitSpeedAtHalfBraking;
3983 if(ExitSpeedHalfSquared < 10)
3993 if(ExitSpeedFullSquared < 10)
4065 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4066 ExitTimeFull =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4090 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4091 ExitTimeHalf =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4101 if(!BuffersOrContinuationNowFlag)
4103 if(NextSpeedLimit < LimitingSpeed)
4105 LimitingSpeed = NextSpeedLimit;
4109 int TempMaxExitSpeed;
4113 if(MaxExitSpeedAtHalfBrakingSquared < 10)
4115 MaxExitSpeedAtHalfBraking = 0;
4119 MaxExitSpeedAtHalfBraking = sqrt(MaxExitSpeedAtHalfBrakingSquared);
4121 if(MaxExitSpeedAtHalfBraking > FrontElementMaxSpeed)
4123 TempMaxExitSpeed = FrontElementMaxSpeed;
4127 TempMaxExitSpeed = MaxExitSpeedAtHalfBraking;
4138 TempBrakeRate = ((
EntrySpeed *
EntrySpeed) - (LimitingSpeed * LimitingSpeed)) / 3.6 / 3.6 / 2 / CumulativeLength;
4151 if(!BuffersOrContinuationNowFlag)
4153 CurrentTrackVectorPosition = NextTrackVectorPosition;
4154 EntryPos = NextEntryPos;
4155 CurrentElementHalfLength = NextElementHalfLength;
4158 ContinuationNextFlag =
true;
4162 while(((CumulativeLength -
FrontElementLength) < DistanceAtHalfBraking) && ((!BuffersOrContinuationNowFlag && !ContinuationNextFlag) ||
4182 if(ExitSpeedHalfSquared < 10)
4192 if(ExitSpeedFullSquared < 10)
4255 double DeltaExitTimeToMaxInSecs;
4256 double DistanceToMax;
4265 DeltaExitTimeToMaxInSecs = 2 * EntryHalfLength * 3.6 /
EntrySpeed;
4267 DistanceToMax = EntryHalfLength;
4270 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4271 ExitTimeFull =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4288 double DeltaExitTimeToMaxInSecs;
4289 double DistanceToMax;
4298 DeltaExitTimeToMaxInSecs = 2 * EntryHalfLength * 3.6 /
EntrySpeed;
4300 DistanceToMax = EntryHalfLength / 2;
4303 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4304 ExitTimeHalf =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4315 if(ExitSpeedHalfSquared < 10)
4325 if(ExitSpeedFullSquared < 10)
4344 if((EntryPos == 0) || (EntryPos == 2))
4366 if(NextTrackVectorPosition > -1)
4368 int NextElementLength;
4369 if(NextEntryPos > 1)
4377 double NextStoppingSpeed = sqrt(3.6 * 3.6 * 2 *
BrakeRate * NextElementLength);
4513 if((Ptr->Command ==
"cdt") || (Ptr->FormatType ==
Repeat))
4517 if((Ptr->ArrivalTime > TDateTime(-1)) && (Ptr->LocationName == Name))
4526 if((Ptr->EventTime > TDateTime(-1)) && (Ptr->LocationName == Name) && (Ptr->Command ==
"pas"))
4551 int CurrentTrackVectorPosition =
LeadElement, NextTrackVectorPosition;
4569 CurrentTrackVectorPosition).
Attribute != 4))
4608 if((EntryPos == 0) || (EntryPos == 2))
4630 CurrentTrackVectorPosition = NextTrackVectorPosition;
4631 EntryPos = NextEntryPos;
4655 throw Exception(
"Error - failed to set ReturnVal in ClearToNextSignal()");
4679 bool PlatformFoundFlag =
false, StopRequired =
false, SkipRouteCheck =
false, RouteOrPartRouteSet =
false;
4680 int CurrentTrackVectorPosition =
LeadElement, NextTrackVectorPosition, ElementNumber = 0, Distance = 0;
4681 int RouteStartPosition;
4683 int PlatformPosition;
4685 int EntryPos =
LeadEntryPos, ExitPos, NextEntryPos, RouteID;
4701 if(Distance > (4000 + LeadElementDistance))
4724 if(OtherTrain.
LeadElement == CurrentTrackVectorPosition)
4727 if((OtherCommand ==
"Fjo") || (OtherCommand ==
"jbo") || (OtherCommand ==
"cdt") || (OtherCommand ==
"Frh") ||
4773 if(!PlatformFoundFlag)
4775 PlatformPosition = CurrentTrackVectorPosition;
4778 PlatformFoundFlag =
true;
4794 if((EntryPos == 0) || (EntryPos == 2))
4838 if(ElementNumber < 2)
4840 SkipRouteCheck =
true;
4844 SkipRouteCheck =
false;
4846 if(ElementNumber == 1)
4848 RouteStartPosition = CurrentTrackVectorPosition;
4858 if(ElementNumber > 1)
4862 RouteOrPartRouteSet =
true;
4866 RouteOrPartRouteSet =
false;
4869 if(!SkipRouteCheck && !RouteOrPartRouteSet)
4876 int ExitLink = CurrentTrackElement.
Link[ExitPos];
4877 if((ExitLink == 1) || (ExitLink == 3) || (ExitLink == 7) || (ExitLink == 9))
4889 Distance += CurrentTrackElement.
Length01;
4893 Distance += CurrentTrackElement.
Length23;
4895 NextTrackVectorPosition = CurrentTrackElement.
Conn[ExitPos];
4896 NextEntryPos = CurrentTrackElement.
ConnLinkPos[ExitPos];
4897 CurrentTrackVectorPosition = NextTrackVectorPosition;
4898 EntryPos = NextEntryPos;
4935 return(RepeatHeadCode);
4957 bool FrontValid =
false, RearValid =
false;
4958 TTrackElement FrontAdjacentTrackElement, RearAdjacentTrackElement;
4962 TrainToBeJoinedBy = NULL;
4976 int TrainToBeJoinedByID = -1;
4997 if((TrainToBeJoinedByID < 0) && RearValid)
5016 if(TrainToBeJoinedByID < 0)
5018 TrainToBeJoinedBy = NULL;
5023 if(!TrainToBeJoinedBy->
Stopped())
5025 TrainToBeJoinedBy = NULL;
5036 TDateTime TimetableNonRepeatTime,
bool Warning)
5071 AnsiString(ActionType) +
"," + LocationName +
"," +
HeadCode);
5072 AnsiString BaseLog =
"", WarningBaseLog =
"", PerfLog =
"", ActionLog =
"";
5073 int IntMinsLate = 0;
5078 ActionLog =
" arrived at ";
5087 ActionLog =
" terminated at ";
5092 ActionLog =
" departed from ";
5094 if(ActionType ==
Pass)
5096 ActionLog =
" passed ";
5100 ActionLog =
" created at ";
5102 if(ActionType ==
Enter)
5104 ActionLog =
" entered railway at ";
5106 if(ActionType ==
Leave)
5108 ActionLog =
" left railway at ";
5112 ActionLog =
" split from front to ";
5116 ActionLog =
" split from rear to ";
5120 ActionLog =
" joined by ";
5124 ActionLog =
" changed direction at ";
5128 ActionLog =
" became new service ";
5132 ActionLog =
" taken under signaller control at ";
5136 ActionLog =
" restored to timetable control at ";
5142 ActionLog =
" REMOVED FROM RAILWAY DUE TO CRASH at ";
5146 ActionLog =
" REMOVED FROM RAILWAY DUE TO DERAILMENT at ";
5150 ActionLog =
" REMOVED FROM RAILWAY at ";
5155 ActionLog =
" received signaller authority to proceed";
5159 ActionLog =
" received signaller authority to step forward";
5163 ActionLog =
" changed direction under signaller control at ";
5167 ActionLog =
" received signaller authority to pass red signal";
5171 ActionLog =
" received signaller instruction to stop";
5175 ActionLog =
" stopped on signaller instruction ";
5179 ActionLog =
" joined under signaller control by ";
5183 ActionLog =
" suffered an onboard power failure at ";
5187 ActionLog =
" failure repaired at ";
5191 ActionLog =
" left railway under signaller control at ";
5193 if(OtherHeadCode !=
"")
5195 OtherHeadCode +=
" at ";
5202 WarningBaseLog =
HeadCode + ActionLog + OtherHeadCode + LocationName;
5208 bool TimePerformance =
true;
5216 TimePerformance =
false;
5220 double MinsLate = ((double)(ActualTime -
GetTrainTime(1, TimetableNonRepeatTime))) * 1440;
5232 IntMinsLate = int(ceil(MinsLate));
5236 IntMinsLate = int(floor(MinsLate));
5238 if(IntMinsLate == 0)
5240 PerfLog =
" on time";
5242 else if(IntMinsLate == 1)
5244 PerfLog =
" 1 minute late";
5246 else if(IntMinsLate == -1)
5248 PerfLog =
" 1 minute early";
5250 else if(IntMinsLate > 1)
5252 PerfLog =
" " + AnsiString(IntMinsLate) +
" minutes late";
5254 else if(IntMinsLate < -1)
5256 int PosIntMinsLate = -IntMinsLate;
5257 PerfLog =
" " + AnsiString(PosIntMinsLate) +
" minutes early";
5259 if(LocationName.Pos(
'-') > 0)
5261 PerfLog =
"," + PerfLog;
5275 if((ActionType ==
Arrive) && (IntMinsLate == 0))
5279 else if((ActionType ==
Arrive) && (IntMinsLate > 0))
5284 else if((ActionType ==
Arrive) && (IntMinsLate < 0))
5289 else if((ActionType ==
Pass) && (IntMinsLate == 0))
5293 else if((ActionType ==
Pass) && (IntMinsLate > 0))
5298 else if((ActionType ==
Pass) && (IntMinsLate < 0))
5303 else if((ActionType ==
Depart) && (IntMinsLate == 0))
5307 else if((ActionType ==
Depart) && (IntMinsLate > 0))
5326 AnsiString LocName =
"";
5392 if(LocationName ==
"")
5396 int FirstNamedElementPos, SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos;
5397 int RearTrainRearPosition, RearTrainFrontPosition, RearTrainExitPos;
5398 int FrontTrainRearPosition, FrontTrainFrontPosition, FrontTrainExitPos;
5402 if(LocationName !=
"")
5410 SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos))
5415 SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos))
5429 int LeadPosA = FirstNamedElementPos;
5430 int LeadPosB = FirstNamedLinkedElementPos;
5431 int LeadPosC = SecondNamedElementPos;
5432 int LeadPosD = SecondNamedLinkedElementPos;
5434 int LeadNumAtLoc = 0;
5451 if(LeadNumAtLoc < 4)
5455 SecondNamedLinkedElementPos))
5457 FirstNamedElementPos = LeadPosA;
5458 FirstNamedLinkedElementPos = LeadPosB;
5459 SecondNamedElementPos = LeadPosC;
5460 SecondNamedLinkedElementPos = LeadPosD;
5464 int MidNumAtLoc = 0;
5481 if(LeadNumAtLoc > MidNumAtLoc)
5484 FirstNamedElementPos = LeadPosA;
5485 FirstNamedLinkedElementPos = LeadPosB;
5486 SecondNamedElementPos = LeadPosC;
5487 SecondNamedLinkedElementPos = LeadPosD;
5501 throw Exception(
"Error - LocationName not set in FrontTrainSplit");
5511 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5512 FrontTrainRearPosition = FirstNamedElementPos;
5513 RearTrainFrontPosition = SecondNamedElementPos;
5514 RearTrainRearPosition = SecondNamedLinkedElementPos;
5518 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5519 FrontTrainRearPosition = SecondNamedElementPos;
5520 RearTrainFrontPosition = FirstNamedElementPos;
5521 RearTrainRearPosition = FirstNamedLinkedElementPos;
5528 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5529 FrontTrainRearPosition = SecondNamedElementPos;
5530 RearTrainFrontPosition = FirstNamedElementPos;
5531 RearTrainRearPosition = FirstNamedLinkedElementPos;
5535 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5536 FrontTrainRearPosition = FirstNamedElementPos;
5537 RearTrainFrontPosition = SecondNamedElementPos;
5538 RearTrainRearPosition = SecondNamedLinkedElementPos;
5541 RearTrainExitPos = -1;
5542 for(
int x = 0; x < 4; x++)
5546 RearTrainExitPos = x;
5550 if(RearTrainExitPos == -1)
5552 throw Exception(
"Error - RearTrainRearPosition not linked to RearTrainFrontPosition in FrontTrainSplit");
5554 FrontTrainExitPos = -1;
5555 for(
int x = 0; x < 4; x++)
5559 FrontTrainExitPos = x;
5563 if(FrontTrainExitPos == -1)
5565 throw Exception(
"Error - FrontTrainRearPosition not linked to FrontTrainFrontPosition in FrontTrainSplit");
5568 int TrainIDOnRearOfRearTrain, TrainIDOnFrontOfRearTrain, TrainIDOnRearOfFrontTrain, TrainIDOnFrontOfFrontTrain;
5575 else if((RearMostElement.
TrackType ==
Bridge) && (RearTrainExitPos < 2))
5595 else if((FrontMostElement.
TrackType ==
Bridge) && (FrontTrainExitPos < 2))
5603 if(((TrainIDOnRearOfRearTrain > -1) && (TrainIDOnRearOfRearTrain !=
TrainID)) || ((TrainIDOnFrontOfRearTrain > -1) && (TrainIDOnFrontOfRearTrain !=
TrainID)
5604 ) || ((TrainIDOnRearOfFrontTrain > -1) && (TrainIDOnRearOfFrontTrain !=
TrainID)) ||
5605 ((TrainIDOnFrontOfFrontTrain > -1) && (TrainIDOnFrontOfFrontTrain !=
TrainID)))
5702 if(LocationName ==
"")
5706 int FirstNamedElementPos, SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos;
5707 int RearTrainRearPosition, RearTrainFrontPosition, RearTrainExitPos;
5708 int FrontTrainRearPosition, FrontTrainFrontPosition, FrontTrainExitPos;
5712 if(LocationName !=
"")
5719 SecondNamedLinkedElementPos))
5723 SecondNamedLinkedElementPos))
5737 int LeadPosA = FirstNamedElementPos;
5738 int LeadPosB = FirstNamedLinkedElementPos;
5739 int LeadPosC = SecondNamedElementPos;
5740 int LeadPosD = SecondNamedLinkedElementPos;
5742 int LeadNumAtLoc = 0;
5759 if(LeadNumAtLoc < 4)
5763 SecondNamedLinkedElementPos))
5765 FirstNamedElementPos = LeadPosA;
5766 FirstNamedLinkedElementPos = LeadPosB;
5767 SecondNamedElementPos = LeadPosC;
5768 SecondNamedLinkedElementPos = LeadPosD;
5772 int MidNumAtLoc = 0;
5789 if(LeadNumAtLoc > MidNumAtLoc)
5792 FirstNamedElementPos = LeadPosA;
5793 FirstNamedLinkedElementPos = LeadPosB;
5794 SecondNamedElementPos = LeadPosC;
5795 SecondNamedLinkedElementPos = LeadPosD;
5809 throw Exception(
"Error - LocationName not set in RearTrainSplit");
5819 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5820 FrontTrainRearPosition = FirstNamedElementPos;
5821 RearTrainFrontPosition = SecondNamedElementPos;
5822 RearTrainRearPosition = SecondNamedLinkedElementPos;
5826 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5827 FrontTrainRearPosition = SecondNamedElementPos;
5828 RearTrainFrontPosition = FirstNamedElementPos;
5829 RearTrainRearPosition = FirstNamedLinkedElementPos;
5836 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5837 FrontTrainRearPosition = SecondNamedElementPos;
5838 RearTrainFrontPosition = FirstNamedElementPos;
5839 RearTrainRearPosition = FirstNamedLinkedElementPos;
5843 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5844 FrontTrainRearPosition = FirstNamedElementPos;
5845 RearTrainFrontPosition = SecondNamedElementPos;
5846 RearTrainRearPosition = SecondNamedLinkedElementPos;
5849 RearTrainExitPos = -1;
5850 for(
int x = 0; x < 4; x++)
5854 RearTrainExitPos = x;
5858 if(RearTrainExitPos == -1)
5860 throw Exception(
"Error - RearTrainRearPosition not linked to RearTrainFrontPosition in RearTrainSplit");
5862 FrontTrainExitPos = -1;
5863 for(
int x = 0; x < 4; x++)
5867 FrontTrainExitPos = x;
5871 if(FrontTrainExitPos == -1)
5873 throw Exception(
"Error - FrontTrainRearPosition not linked to FrontTrainFrontPosition in RearTrainSplit");
5876 int TrainIDOnRearOfRearTrain, TrainIDOnFrontOfRearTrain, TrainIDOnRearOfFrontTrain, TrainIDOnFrontOfFrontTrain;
5883 else if((RearMostElement.
TrackType ==
Bridge) && (RearTrainExitPos < 2))
5903 else if((FrontMostElement.
TrackType ==
Bridge) && (FrontTrainExitPos < 2))
5911 if(((TrainIDOnRearOfRearTrain > -1) && (TrainIDOnRearOfRearTrain !=
TrainID)) || ((TrainIDOnFrontOfRearTrain > -1) && (TrainIDOnFrontOfRearTrain !=
TrainID)
5912 ) || ((TrainIDOnRearOfFrontTrain > -1) && (TrainIDOnRearOfFrontTrain !=
TrainID)) ||
5913 ((TrainIDOnFrontOfFrontTrain > -1) && (TrainIDOnFrontOfFrontTrain !=
TrainID)))
6052 TTrain *TrainToBeJoinedBy;
6085 double OtherBrakeForce = TrainToBeJoinedBy->
MaxBrakeRate * TrainToBeJoinedBy->
Mass;
6087 double CombinedBrakeRate = (OtherBrakeForce + OwnBrakeForce) / (TrainToBeJoinedBy->
Mass +
Mass);
6144 int RouteNumber = -1;
6152 bool FirstPass =
true;
6157 if(FirstPass && (TVPos2 != FirstRouteElementVecPos))
6260 for(
int x = 0; x < IncNum; x++)
6293 else if(Ptr->
Command ==
"jbo")
6304 throw Exception(
"Error - illegal command in SendMissedActionLogs for IncNum = " + AnsiString(IncNum) +
", and command = " + Ptr->
Command);
6310 bool IncludeFER =
false;
6318 if(!IncludeFER && (Ptr->
Command ==
"Fer"))
6323 else if(IncludeFER && (Ptr->
Command ==
"Fer"))
6334 else if(Ptr->
Command ==
"Fjo")
6340 else if(Ptr->
Command ==
"Frh")
6350 else if(Ptr->
Command ==
"Frh-sh")
6401 else if(Ptr->
Command ==
"jbo")
6406 else if(Ptr->
Command ==
"cdt")
6414 throw Exception(
"Error - illegal command in SendMissedActionLogs for IncNum = " + AnsiString(IncNum) +
", and command = " + Ptr->
Command);
6786 int RouteNumber = -1;
6794 bool FirstPass =
true;
6799 if(FirstPass && (TVPos2 != FirstRouteElementVecPos))
6827 ",FloatingLabelNextString" +
"," +
HeadCode);
6828 AnsiString RetStr =
"", LocationName =
"";
6832 throw Exception(
"Error - start entry in FloatingLabelNextString");
6872 else if(Ptr->
Command ==
"Fns")
6878 else if(Ptr->
Command ==
"F-nshs")
6909 RetStr =
"None, train terminated at " + Ptr->
LocationName;
6911 else if(Ptr->
Command ==
"Frh")
6913 RetStr =
"None, train terminated at " + Ptr->
LocationName;
6915 else if(Ptr->
Command ==
"Fer")
6917 AnsiString AllowedExits =
"";
6920 else if(Ptr->
Command ==
"Fjo")
6925 else if(Ptr->
Command ==
"jbo")
6930 else if(Ptr->
Command ==
"fsp")
6935 else if(Ptr->
Command ==
"rsp")
6940 else if(Ptr->
Command ==
"cdt")
6953 + AnsiString(RptNum) +
",CheckNewServiceDepartureTime," +
HeadCode);
6954 AnsiString DepTime =
"", EventTime =
"";
6955 bool CDTFlag =
false;
6959 if(AVI->Command ==
"cdt")
6964 if((AVI->Command ==
"fsp") || (AVI->Command ==
"rsp"))
6967 RetStr +=
"\nNew service splits at " + EventTime;
6971 if(AVI->Command ==
"jbo")
6974 RetStr +=
"\nNew service joined by " + AVI->OtherHeadCode +
" at " + EventTime;
6978 if((AVI->FormatType ==
TimeLoc) && (AVI->DepartureTime > TDateTime(-1)))
6983 RetStr +=
"\nNew service changes direction then departs at " + DepTime;
6987 RetStr +=
"\nNew service departs at " + DepTime;
7003 ",FloatingTimetableString" +
"," +
HeadCode);
7004 AnsiString RetStr =
"", PartStr =
"";
7010 throw Exception(
"Error - start entry in FloatingTimetableString");
7013 bool FirstPass =
true;
7026 AnsiString TrainLoc =
"";
7064 AnsiString TrainLoc =
"";
7092 else if(Ptr->
Command ==
"Fns")
7098 else if(Ptr->
Command ==
"F-nshs")
7131 else if(Ptr->
Command ==
"Frh")
7135 else if(Ptr->
Command ==
"Fer")
7137 AnsiString AllowedExits =
"";
7140 else if(Ptr->
Command ==
"Fjo")
7145 else if(Ptr->
Command ==
"jbo")
7150 else if(Ptr->
Command ==
"fsp")
7155 else if(Ptr->
Command ==
"rsp")
7160 else if(Ptr->
Command ==
"cdt")
7166 RetStr = RetStr +
'\n' + PartStr;
7183 RetStr =
"Timetable finished";
7187 RetStr =
"No timetable";
7344 bool ForwardHeadCode;
7348 ForwardHeadCode =
true;
7353 ForwardHeadCode =
false;
7496 if(ColourNumber == 0)
7500 else if(ColourNumber == 1)
7504 else if(ColourNumber == 2)
7508 else if(ColourNumber == 3)
7512 else if(ColourNumber == 4)
7516 else if(ColourNumber == 5)
7520 else if(ColourNumber == 6)
7524 else if(ColourNumber == 7)
7528 else if(ColourNumber == 8)
7532 else if(ColourNumber == 9)
7536 else if(ColourNumber == 10)
7540 else if(ColourNumber == 11)
7544 else if(ColourNumber == 12)
7548 else if(ColourNumber == 13)
7552 else if(ColourNumber == 14)
7564 for(
int x = 0; x < 4; x++)
7571 for(
int x = 0; x < 4; x++)
7656 if((LocationAndMarker[1] !=
'*') && (LocationAndMarker.Length() > 6))
7659 AnsiString Location = LocationAndMarker.SubString(1, LocationAndMarker.Length() - 6);
7660 bool GiveMessagesFalse =
false;
7661 bool CheckLocationsExistInRailwayTrue =
true;
7668 AnsiString Marker = LocationAndMarker.SubString(LocationAndMarker.Length() - 5, 6);
7671 if(Marker[6] ==
'1')
8136 bool HideFlashingTrain =
true;
8139 Graphics::TBitmap *SmallTrainBitmap;
8180 HideFlashingTrain =
false;
8185 HideFlashingTrain =
false;
8190 HideFlashingTrain =
false;
8195 HideFlashingTrain =
false;
8200 HideFlashingTrain =
false;
8204 if((
LeadElement > -1) && (!HideFlashingTrain || Flash))
8208 if((
MidElement > -1) && (!HideFlashingTrain || Flash))
8232 for(
int y = 0; y < 3; y++)
8236 bool FoundFlag =
false;
8247 if(IMPair.first != IMPair.second)
8274 if((LocationName ==
"") && (
MidElement > -1))
8278 if((LocationName ==
"") && (
LagElement > -1))
8282 if(LocationName ==
"")
8284 throw Exception(
"Error - Location name not set in TrainAtLocation");
8295 for(
int x = 0; x < 4; x++)
8307 for(
int x = 0; x < 4; x++)
8324 AnsiString(LinkNumber) +
"," +
HeadCode);
8375 int DistanceToRedSignal = 0;
8376 float TimeToAct = 0;
8377 float MinsEarly = 0;
8378 TDateTime DepartureTime;
8379 TDateTime ArrivalTime;
8425 float CurrentStopTime;
8426 float LaterStopTime;
8427 float RecoverableTime;
8432 if(DistanceToRedSignal == -1)
8451 float TimeToSubtract, TotalStopTime;
8454 TimeToSubtract = RecoverableTime;
8498 if(CurrentStopTime > 0)
8500 TotalStopTime = CurrentStopTime + LaterStopTime;
8509 else if((MinsEarly > 0) && !
Stopped())
8511 TotalStopTime = LaterStopTime + MinsEarly;
8515 if(LaterStopTime == 0)
8517 TotalStopTime = CurrentStopTime;
8523 TotalStopTime = CurrentStopTime + LaterStopTime - TimeToSubtract;
8526 if(AvTrackSpeed < 30)
8530 int Speed = AvTrackSpeed;
8540 TimeToAct = TotalStopTime + DistanceToRedSignal * 3.6 / 60 / Speed;
8562 if((NextEntryPos == 0) || (NextEntryPos == 2))
8682 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
8725 int IncrementalMinutes = 0;
8726 int IncrementalDigits = 0;
8734 throw Exception(
"Error - Repeat entry && less than two trains for Snt entry: " + TDEntry.
HeadCode);
8763 if(AVEntry0.
Command ==
"Snt-sh")
8768 int IncrementalMinutes = 0;
8769 int IncrementalDigits = 0;
8777 throw Exception(
"Error - Repeat entry && less than two trains for Snt-sh entry: " + TDEntry.
HeadCode);
8809 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
8869 AnsiString Loc =
"";
8870 bool ElementFound =
false;
8875 ElementFound =
true;
8880 ElementFound =
true;
8885 ElementFound =
true;
8914 else if(AVEntryPtr->
Command ==
"Fer")
8916 bool CorrectExit =
false;
9024 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9039 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9054 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9065 bool TTrainController::AddTrain(
int Caller,
int RearPosition,
int FrontPosition, AnsiString HeadCode,
int StartSpeed,
int Mass,
double MaxRunningSpeed,
9066 double MaxBrakeRate,
double PowerAtRail, AnsiString ModeStr,
TTrainDataEntry *TrainDataEntryPtr,
int RepeatNumber,
int IncrementalMinutes,
9067 int IncrementalDigits,
int SignallerSpeed,
bool SignallerControl,
TActionEventType &EventType)
9069 LogEvent(AnsiString(Caller) +
",AddTrain," + AnsiString(RearPosition) +
"," + AnsiString(FrontPosition) +
"," + HeadCode +
"," + AnsiString(StartSpeed) +
9070 "," + AnsiString(Mass) +
"," + ModeStr);
9072 "," + HeadCode +
"," + AnsiString(StartSpeed) +
"," + AnsiString(Mass) +
"," + ModeStr +
"," + HeadCode);
9074 int RearExitPos = -1;
9076 for(
int x = 0; x < 4; x++)
9083 if(RearExitPos == -1)
9085 throw Exception(
"Error, RearExit == -1 in AddTrain");
9087 bool ReportFlag =
true;
9104 if(ModeStr ==
"Timetable")
9110 if(MaxRunningSpeed < 10)
9112 MaxRunningSpeed = 10;
9114 if(SignallerSpeed < 10)
9116 SignallerSpeed = 10;
9118 TTrain *NewTrain =
new TTrain(0, RearPosition, RearExitPos, HeadCode, StartSpeed, Mass, MaxRunningSpeed, MaxBrakeRate, PowerAtRail, TrainMode,
9119 TrainDataEntryPtr, RepeatNumber, IncrementalMinutes, IncrementalDigits, SignallerSpeed);
9124 if(SignallerControl)
9154 if(!SignallerControl)
9169 if(!SignallerControl)
9180 AnsiString Loc =
"";
9197 if(!SignallerControl)
9216 int RouteNumber = -1;
9217 bool SignalsSet =
false;
9224 int RouteStartPosition;
9228 if(FirstPair.first == RouteNumber)
9230 RouteStartPosition = FirstPair.second;
9232 else if(SecondPair.first == RouteNumber)
9234 RouteStartPosition = SecondPair.second;
9238 throw Exception(
"Error, RouteNumber not found in Route2MultiMap in 1st of 2 calls to SetAllRearwardsSignals in AddTrain");
9244 else if(RouteNumber > -1)
9264 int LinkedRouteNumber = -1;
9285 int RouteStartPosition;
9289 if(FirstPair.first == RouteNumber)
9291 RouteStartPosition = FirstPair.second;
9293 else if(SecondPair.first == RouteNumber)
9295 RouteStartPosition = SecondPair.second;
9299 throw Exception(
"Error, RouteNumber not found in Route2MultiMap in 2nd of 2 calls to SetAllRearwardsSignals in AddTrain");
9305 else if(RouteNumber > -1)
9325 int LinkedRouteNumber = -1;
9346 AnsiString(TrackVectorNumber));
9349 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9358 throw Exception(
"Error, VecPos not set in EntryPos");
9360 if(
TrainVectorAt(2, VecPos).LeadElement == TrackVectorNumber)
9365 else if(
TrainVectorAt(4, VecPos).MidElement == TrackVectorNumber)
9370 else if(
TrainVectorAt(6, VecPos).LagElement == TrackVectorNumber)
9384 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9392 throw Exception(
"Error - No Train identified in TrainVectorAtIdent with ID = " + AnsiString(TrainID));
9402 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9432 AnsiString RetStr =
"", PartStr =
"";
9440 if((Ptr->Command !=
"") && (Ptr->Command[1] ==
'S'))
9448 if(Ptr->SignallerControl)
9450 RetStr =
"Train under signaller control";
9455 if(Ptr->ArrivalTime == Ptr->DepartureTime)
9466 else if((Ptr->FormatType ==
TimeLoc) && (Ptr->ArrivalTime != TDateTime(-1)))
9470 else if((Ptr->FormatType ==
TimeLoc) && (Ptr->ArrivalTime == TDateTime(-1)))
9474 else if(Ptr->FormatType ==
PassTime)
9478 else if(Ptr->Command ==
"Fns")
9484 else if(Ptr->Command ==
"F-nshs")
9487 Ptr->NonRepeatingShuttleLinkHeadCode +
" at " + Ptr->LocationName;
9494 else if((Ptr->Command ==
"Fns-sh") && (RepNum < (TTDEPtr->
NumberOfTrains - 1)))
9501 else if((Ptr->Command ==
"Fns-sh") && (RepNum >= (TTDEPtr->
NumberOfTrains - 1)))
9504 Ptr->NonRepeatingShuttleLinkHeadCode, +
" at " + Ptr->LocationName;
9507 else if((Ptr->Command ==
"Frh-sh") && (RepNum < (TTDEPtr->
NumberOfTrains - 1)))
9514 else if((Ptr->Command ==
"Frh-sh") && (RepNum >= (TTDEPtr->
NumberOfTrains - 1)))
9516 PartStr =
"Terminate at " + Ptr->LocationName;
9518 else if(Ptr->Command ==
"Frh")
9520 PartStr =
"Terminate at " + Ptr->LocationName;
9522 else if(Ptr->Command ==
"Fer")
9524 AnsiString AllowedExits;
9528 else if(Ptr->Command ==
"Fjo")
9531 Ptr->OtherHeadCode, RepNum, IncDig) +
" at " + Ptr->LocationName;
9533 else if(Ptr->Command ==
"jbo")
9536 (50, Ptr->OtherHeadCode, RepNum, IncDig) +
" at " + Ptr->LocationName;
9538 else if(Ptr->Command ==
"fsp")
9543 else if(Ptr->Command ==
"rsp")
9548 else if(Ptr->Command ==
"cdt")
9554 RetStr = RetStr +
'\n' + PartStr;
9562 while(Ptr < TTDEPtr->ActionVector.end() && (Count < 33) && ((Ptr->Command ==
"") || ((Ptr->Command !=
"") && (Ptr->Command[1] !=
'F'))));
9575 + AnsiString(RptNum) +
",ControllerCheckNewServiceDepartureTime," + TDEPtr->
HeadCode);
9576 AnsiString DepTime =
"", EventTime =
"";
9577 bool CDTFlag =
false;
9581 if(AVI->Command ==
"cdt")
9586 if((AVI->Command ==
"fsp") || (AVI->Command ==
"rsp"))
9589 RetStr +=
"\nNew service splits at " + EventTime;
9593 if(AVI->Command ==
"jbo")
9596 RetStr +=
"\nNew service joined by " + AVI->OtherHeadCode +
" at " + EventTime;
9600 if((AVI->FormatType ==
TimeLoc) && (AVI->DepartureTime > TDateTime(-1)))
9605 RetStr +=
"\nNew service changes direction then departs at " + DepTime;
9609 RetStr +=
"\nNew service departs at " + DepTime;
9768 ActiveTrackElementNameMapEntry.first =
Track->
TrackVector.at(x).ActiveTrackElementName;
9769 ActiveTrackElementNameMapEntry.second = 0;
9775 std::ifstream TTBLFile(FileName, std::ios_base::binary);
9778 if(TTBLFile.is_open())
9780 char *TrainTimetableString =
new char[10000];
9782 bool EndOfFile =
false;
9785 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
9787 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
9794 delete[] TrainTimetableString;
9798 AnsiString OneLine(TrainTimetableString);
9799 bool FinalCallFalse =
false;
9800 while((Count == 0) && !
ProcessOneTimetableLine(5, Count, OneLine, EndOfFile, FinalCallFalse, GiveMessages, CheckLocationsExistInRailway))
9804 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
9805 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
9810 TimetableMessage(GiveMessages,
"Timetable invalid - unable to find a valid start time on its own line");
9812 delete[] TrainTimetableString;
9816 OneLine = AnsiString(TrainTimetableString);
9822 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
9824 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
9834 OneLine = AnsiString(TrainTimetableString);
9836 if(OneLine.Length() > 9999)
9838 TimetableMessage(GiveMessages,
"Timetable contains a line that is too long - 10,000 or more characters!");
9840 delete[] TrainTimetableString;
9844 bool FinalCallFalse =
false;
9845 if(!
ProcessOneTimetableLine(6, Count, OneLine, EndOfFile, FinalCallFalse, GiveMessages, CheckLocationsExistInRailway))
9849 delete[] TrainTimetableString;
9853 if(EndOfFile && (Count < 2))
9856 TimetableMessage(GiveMessages,
"Timetable has too few or no relevant entries - must have a start time on its own line and at least one train");
9858 delete[] TrainTimetableString;
9864 delete[] TrainTimetableString;
9869 TimetableMessage(GiveMessages,
"Failed to open timetable file, make sure it's not open in another application");
9880 bool CheckLocationsExistInRailway)
10005 AnsiString((
short)FinalCall) +
"," + AnsiString((
short)CheckLocationsExistInRailway));
10015 if(OneLine[1] !=
'*')
10017 int SCPos = OneLine.Pos(
';');
10028 bool AllCommas =
true;
10030 for(
int x = 1; x < OneLine.Length() + 1; x++)
10032 if(OneLine[x] !=
',')
10037 if(AllCommas || (OneLine ==
""))
10052 AnsiString First =
"", Second =
"", Third =
"", Fourth =
"";
10053 int RearStartOrRepeatMins = 0, FrontStartOrRepeatDigits = 0, NumberOfRepeats = 0;
10054 TDateTime EventTime(0), ArrivalTime(0), DepartureTime(0);
10055 TDateTime StartTime(0);
10057 bool Warning =
false;
10084 AnsiString TrainInfoStr =
"", HeadCode =
"", Description =
"";
10085 int StartSpeed = 0, MaxRunningSpeed = 0, Mass = 0;
10086 double MaxBrakeRate = 0;
10087 double PowerAtRail = 0;
10088 int SignallerSpeed = 0;
10089 if(OneLine[1] ==
'*')
10095 int Pos = OneLine.Pos(
',');
10098 int SubStringLength = 20;
10099 if(OneLine.Length() < 20)
10101 SubStringLength = OneLine.Length();
10103 TimetableMessage(GiveMessages,
"Error in timetable - entry incomplete: see '" + OneLine.SubString(1, SubStringLength) +
"'....");
10107 TrainInfoStr = OneLine.SubString(1, Pos - 1);
10108 if(!
SplitTrainInfo(0, TrainInfoStr, HeadCode, Description, StartSpeed, MaxRunningSpeed, Mass, MaxBrakeRate, PowerAtRail, SignallerSpeed,
10118 TempTrainDataEntry.
HeadCode = HeadCode;
10122 TempTrainDataEntry.
Mass = Mass;
10130 AnsiString NewRemainder = OneLine.SubString(Pos + 1, OneLine.Length() - Pos);
10133 while(NewRemainder[NewRemainder.Length()] ==
',')
10135 if(NewRemainder.Length() > 1)
10137 NewRemainder = NewRemainder.SubString(1, NewRemainder.Length() - 1);
10146 if(NewRemainder ==
"")
10148 TimetableMessage(GiveMessages,
"Error in timetable - no events following train: '" + OneLine +
"'");
10153 int CommaCount = 0;
10154 for(
int x = 1; x < NewRemainder.Length() + 1; x++)
10156 if(NewRemainder[x] ==
',')
10161 if(CommaCount == 0)
10163 if((NewRemainder.SubString(7, 3) !=
"Snt") || (NewRemainder[NewRemainder.Length()] !=
'S'))
10165 int SubStringLength = 20;
10166 if(OneLine.Length() < 20)
10168 SubStringLength = OneLine.Length();
10171 "Error in timetable - must have at least a start and a finish event for a train that is not started under signaller control - see line beginning: '" +
10172 OneLine.SubString(1, SubStringLength) +
"'....");
10177 AnsiString OneEntry =
"";
10182 bool FinishFlag =
false;
10183 for(
int x = 0; x < CommaCount + 1; x++)
10185 if((CommaCount == 0) || (x < CommaCount))
10190 if(CommaCount == 0)
10192 OneEntry = NewRemainder;
10197 Pos = NewRemainder.Pos(
',');
10198 OneEntry = NewRemainder.SubString(1, Pos - 1);
10199 NewRemainder = NewRemainder.SubString(Pos + 1, NewRemainder.Length() - Pos);
10205 RearStartOrRepeatMins = 0;
10206 FrontStartOrRepeatDigits = 0;
10207 NumberOfRepeats = 0;
10208 if(!
SplitEntry(0, OneEntry, GiveMessages, CheckLocationsExistInRailway, First, Second, Third, Fourth, RearStartOrRepeatMins,
10209 FrontStartOrRepeatDigits, FormatType, LocationType, SequenceType, ShuttleLinkType, ExitList, Warning))
10211 TimetableMessage(GiveMessages,
"Error in timetable - Event: '" + OneEntry +
"'");
10216 if(Warning && (Second ==
"Frh"))
10218 TimetableMessage(GiveMessages,
"Error in line - '" + OneEntry +
"': warnings cannot be given for 'Frh' events");
10222 if(Warning && (Second ==
"Fjo"))
10225 "': warnings cannot be given for 'Fjo' events, for a train join warning add a 'W' prefix to the 'jbo' event");
10231 if(SequenceType !=
Start)
10233 TimetableMessage(GiveMessages,
"Error in timetable - First event not a start event: '" + OneEntry +
"'");
10237 if((Second ==
"Snt") && (Fourth ==
'S') && (NewRemainder !=
""))
10239 if(NewRemainder[1] !=
'R')
10242 "Error in timetable - the only event that can follow a train created under signaller control is a repeat, see '" +
10248 if((Second ==
"Snt") || (Second ==
"Snt-sh"))
10252 if((HeadCode ==
"") || (Description ==
"") || (MaxRunningSpeed == 0) || (Mass == 0) || (MaxBrakeRate == 0))
10255 TimetableMessage(GiveMessages,
"Error in timetable - train information incomplete before 'Snt' or 'Snt-sh' start event: '" +
10261 if((Second ==
"Sfs") || (Second ==
"Sns") || (Second ==
"Sns-sh") || (Second ==
"Sns-fsh"))
10266 TimetableMessage(GiveMessages,
"Error in timetable - headcode missing before 'Sfs', 'Sns', 'Sns-sh' or 'Sns-fsh' start event: '" +
10271 if((StartSpeed != 0) || (MaxRunningSpeed != 0) || (Mass != 0) || (MaxBrakeRate != 0) || (PowerAtRail != 0))
10274 "Error in timetable - information additional to a headcode & optional description given before 'Sfs', 'Sns', 'Sns-sh' or 'Sns-fsh' start event: '" +
10281 if(SequenceType ==
Finish)
10290 TDateTime TempTime;
10296 ActionVectorEntry.
Warning = Warning;
10312 ActionVectorEntry.
Command = Second;
10327 else if(FormatType ==
TimeCmd)
10333 ActionVectorEntry.
Command = Second;
10341 ActionVectorEntry.
Command = Second;
10342 ActionVectorEntry.
ExitList = ExitList;
10350 ActionVectorEntry.
Command = Second;
10364 ActionVectorEntry.
Command = Second;
10375 ActionVectorEntry.
Command = Second;
10385 ActionVectorEntry.
Command = Second;
10394 ActionVectorEntry.
Command = Second;
10403 ActionVectorEntry.
Command = Second;
10409 ActionVectorEntry.
Command = Second;
10411 TempTrainDataEntry.
ActionVector.push_back(ActionVectorEntry);
10416 OneEntry = NewRemainder;
10421 RearStartOrRepeatMins = 0;
10422 FrontStartOrRepeatDigits = 0;
10423 NumberOfRepeats = 0;
10424 if((FinishFlag) && (OneEntry[1] !=
'R'))
10427 TimetableMessage(GiveMessages,
"Error in timetable - Last event = '" + OneEntry +
"'. An earlier finish event has been found with something other than a repeat following it - only a repeat can follow a finish event.");
10431 if(OneEntry[1] !=
'R')
10433 if(!
SplitEntry(1, OneEntry, GiveMessages, CheckLocationsExistInRailway, First, Second, Third, Fourth, RearStartOrRepeatMins,
10434 FrontStartOrRepeatDigits, FormatType, LocationType, SequenceType, ShuttleLinkType, ExitList, Warning))
10436 TimetableMessage(GiveMessages,
"Error in timetable - Event: '" + OneEntry +
"'");
10440 if(SequenceType !=
Finish)
10442 TimetableMessage(GiveMessages,
"Error in timetable - last event should be a finish: '" + OneEntry +
"'");
10449 TDateTime TempTime;
10455 ActionVectorEntry.
Warning = Warning;
10462 ActionVectorEntry.
Command = Second;
10470 ActionVectorEntry.
Command = Second;
10479 ActionVectorEntry.
Command = Second;
10488 ActionVectorEntry.
Command = Second;
10498 ActionVectorEntry.
Command = Second;
10499 ActionVectorEntry.
ExitList = ExitList;
10503 ActionVectorEntry.
Command = Second;
10505 TempTrainDataEntry.
ActionVector.push_back(ActionVectorEntry);
10510 if(!
SplitRepeat(0, OneEntry, RearStartOrRepeatMins, FrontStartOrRepeatDigits, NumberOfRepeats, GiveMessages))
10526 TempTrainDataEntry.
ActionVector.push_back(ActionVectorEntry);
10545 if((HeadCode[HeadCode.Length() - 1] <
'0') || (HeadCode[HeadCode.Length() - 1] >
'9'))
10550 if((HeadCode[HeadCode.Length()] <
'0') || (HeadCode[HeadCode.Length()] >
'9'))
10565 if(TimeStr.Length() < 5)
10570 if((TimeStr[1] <
'0') || (TimeStr[1] >
'9'))
10575 if((TimeStr[2] <
'0') || (TimeStr[2] >
'9'))
10580 if(TimeStr[3] !=
':')
10585 if((TimeStr[4] <
'0') || (TimeStr[4] >
'5'))
10590 if((TimeStr[5] <
'0') || (TimeStr[5] >
'9'))
10595 while(TimeStr.Length() > 5)
10597 TimeStr = TimeStr.SubString(1, TimeStr.Length() - 1);
10599 double WholeHours = (AnsiString(TimeStr[1]) + AnsiString(TimeStr[2])).ToDouble();
10600 double FracHour = ((AnsiString(TimeStr[4]) + AnsiString(TimeStr[5])).ToDouble()) / 60.0;
10602 if((WholeHours + FracHour) >= 95.98334)
10607 Time = TDateTime((WholeHours + FracHour) / 24);
10614 bool TTrainController::SplitEntry(
int Caller, AnsiString OneEntry,
bool GiveMessages,
bool CheckLocationsExistInRailway, AnsiString &First, AnsiString &Second,
10615 AnsiString &Third, AnsiString &Fourth,
int &RearStartOrRepeatMins,
int &FrontStartOrRepeatDigits,
TTimetableFormatType &FormatType,
10624 TDateTime TempTime;
10626 if(OneEntry.Length() > 0)
10628 if(OneEntry[1] ==
'W')
10631 OneEntry = OneEntry.SubString(2, OneEntry.Length() - 1);
10635 if(OneEntry ==
"Frh")
10645 if(OneEntry.Length() < 7)
10650 int Pos = OneEntry.Pos(
';');
10658 First = OneEntry.SubString(1, 5);
10664 AnsiString Remainder = OneEntry.SubString(Pos + 1, OneEntry.Length() - Pos);
10666 if((Remainder[1] >=
'0') && (Remainder[1] <=
'9'))
10669 if(Remainder.Length() < 7)
10674 Pos = Remainder.Pos(
';');
10681 Second = Remainder.SubString(1, 5);
10687 Third = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
10700 Pos = Remainder.Pos(
';');
10703 Second = Remainder;
10704 if(Second ==
"cdt")
10729 if((Pos != 4) && (Pos != 7) && (Pos != 8))
10735 Second = Remainder.SubString(1, Pos - 1);
10737 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
10739 Pos = Remainder.Pos(
';');
10746 Third = Remainder.SubString(1, Pos - 1);
10747 Fourth = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
10749 if((Second ==
"Snt") || (Second ==
"Snt-sh"))
10752 int SpacePos = Third.Pos(
' ');
10758 AnsiString RearStartStr = Third.SubString(1, SpacePos - 1);
10759 AnsiString FrontStartStr = Third.SubString(SpacePos + 1, Third.Length() - SpacePos);
10761 if(CheckLocationsExistInRailway)
10771 if(Second ==
"Snt")
10774 SequenceType =
Start;
10783 SequenceType =
Start;
10794 if(Second ==
"Sns-sh")
10798 SequenceType =
Start;
10813 if(Second ==
"F-nshs")
10827 if(Second ==
"Sns-fsh")
10831 SequenceType =
Start;
10841 if(Second ==
"Fns-sh")
10861 if(Second ==
"pas")
10876 if(Second ==
"Fer")
10883 if(CheckLocationsExistInRailway)
10895 if((Second !=
"Fns") && (Second !=
"Fjo") && (Second !=
"jbo") && (Second !=
"fsp") && (Second !=
"rsp") && (Second !=
"Sfs") && (Second !=
"Sns") &&
10896 (Second !=
"Frh-sh"))
10908 if(Second ==
"Frh-sh")
10916 if((Second ==
"Fns") || (Second ==
"Fjo") || (Second ==
"Frh-sh"))
10920 if((Second ==
"jbo") || (Second ==
"fsp") || (Second ==
"rsp"))
10924 if((Second ==
"Sfs") || (Second ==
"Sns"))
10926 SequenceType =
Start;
10944 if((LocStr[1] >=
'0') && (LocStr[1] <=
'9'))
10949 for(
int x = 1; x < LocStr.Length() + 1; x++)
10951 if(LocStr[x] <
' ')
10956 if(LocStr[x] >
'z')
10963 if(CheckLocationsExistInRailway)
10968 "' appears in the timetable but is not a valid name. To be valid the name must be a stopping location and apply to one or more platforms " +
10969 "(not concourses on their own), or to track at a blue non-station named location. BUT NOTE THAT trains can't stop at continuations so a name " +
10970 "that includes a continuation will not be valid.");
10988 if((HeadCode.Length() < 4) || (HeadCode.Length() > 8))
10991 "', length must be between 4 and 8 characters, and last 4 must be a legitimate headcode. This error can also be caused by omitting a service reference after Snt-sh, Sns-sh, Fns-sh or Frh-sh");
10996 for(
int x = 1; x < (HeadCode.Length() + 1); x++)
10998 if((HeadCode[x] <
' ') || (HeadCode[x] >
'~'))
11000 TimetableMessage(GiveMessages,
"Non-printable character in headcode '" + HeadCode +
"'");
11006 for(
int x = 3; x >= 0; x--)
11008 if(((HeadCode[HeadCode.Length() - x] <
'A') || (HeadCode[HeadCode.Length() - x] >
'Z')) && ((HeadCode[HeadCode.Length() - x] <
'a') ||
11009 (HeadCode[HeadCode.Length() - x] >
'z')) && ((HeadCode[HeadCode.Length() - x] <
'0') || (HeadCode[HeadCode.Length() - x] >
'9')))
11011 TimetableMessage(GiveMessages,
"Headcode error in '" + HeadCode +
"', headcode must consist of letters and digits only");
11027 AnsiString CurrentID =
"";
11029 if(IDSet.Length() == 0)
11031 TimetableMessage(GiveMessages,
"Must have at least one exit element ID following 'Fer'");
11035 for(
int x = 1; x <= IDSet.Length(); x++)
11038 if(((C <
'0') || (C >
'9')) && (C !=
' ') && (C !=
'N') && (C !=
'-'))
11040 TimetableMessage(GiveMessages,
"Illegal character in the set of element IDs following 'Fer' in '" + IDSet +
"'");
11045 int Pos = IDSet.Pos(
' ');
11056 CurrentID = IDSet.SubString(1, Pos - 1);
11057 IDSet = IDSet.SubString(Pos + 1, IDSet.Length() - Pos);
11069 TimetableMessage(GiveMessages,
"The element ID '" + CurrentID +
"' following 'Fer' is not an exit");
11076 if(!ExitList.empty())
11080 if(*ELIT == VecPos)
11082 TimetableMessage(GiveMessages,
"The element ID '" + CurrentID +
"' following 'Fer' duplicates an earlier element");
11089 ExitList.push_back(VecPos);
11099 Pos = IDSet.Pos(
' ');
11106 int &Mass,
double &MaxBrakeRate,
double &PowerAtRail,
int &SignallerSpeed,
bool GiveMessages)
11113 AnsiString Remainder =
"";
11114 int SemiColonCount = 0;
11116 for(
int x = 1; x < TrainInfoStr.Length() + 1; x++)
11118 if(TrainInfoStr[x] ==
';')
11123 if((SemiColonCount != 6) && (SemiColonCount != 7) && (SemiColonCount != 1) && (SemiColonCount != 0))
11125 TimetableMessage(GiveMessages,
"Error in train information in '" + TrainInfoStr +
11126 "'. Should be headcode + optional description for a continuing service;" +
11127 " or headcode, description, start speed, max running speed, mass, brake force, power (and optional signaller max. speed) for a new service");
11131 if(SemiColonCount == 0)
11133 HeadCode = TrainInfoStr;
11142 if(SemiColonCount == 1)
11144 Pos = TrainInfoStr.Pos(
';');
11145 HeadCode = TrainInfoStr.SubString(1, Pos - 1);
11146 Description = TrainInfoStr.SubString(Pos + 1, TrainInfoStr.Length() - Pos);
11152 if(Description ==
"")
11154 TimetableMessage(GiveMessages,
"Train description missing in '" + TrainInfoStr +
"'");
11158 if(Description.Length() > 60)
11160 TimetableMessage(GiveMessages,
"Train description too long, limit of 60 characters '" + TrainInfoStr +
"'");
11164 for(
int x = 1; x < Description.Length() + 1; x++)
11166 if((Description[x] <
' ') || (Description[x] >
'~'))
11168 TimetableMessage(GiveMessages,
"Train description contains invalid characters in '" + TrainInfoStr +
"'");
11177 Pos = TrainInfoStr.Pos(
';');
11178 HeadCode = TrainInfoStr.SubString(1, Pos - 1);
11179 Remainder = TrainInfoStr.SubString(Pos + 1, TrainInfoStr.Length() - Pos);
11185 Pos = Remainder.Pos(
';');
11186 Description = Remainder.SubString(1, Pos - 1);
11187 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11188 if(Description ==
"")
11190 TimetableMessage(GiveMessages,
"Train description missing in '" + TrainInfoStr +
"'");
11194 if(Description.Length() > 60)
11196 TimetableMessage(GiveMessages,
"Train description too long, limit of 60 characters '" + TrainInfoStr +
"'");
11200 for(
int x = 1; x < Description.Length() + 1; x++)
11202 if((Description[x] <
' ') || (Description[x] > 126))
11204 TimetableMessage(GiveMessages,
"Train description contains invalid characters in '" + TrainInfoStr +
"'");
11209 Pos = Remainder.Pos(
';');
11210 AnsiString StartSpeedStr = Remainder.SubString(1, Pos - 1);
11212 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11213 if(StartSpeedStr ==
"")
11215 TimetableMessage(GiveMessages,
"Train starting speed missing in '" + TrainInfoStr +
"'");
11219 for(
int x = 1; x < StartSpeedStr.Length() + 1; x++)
11221 if((StartSpeedStr[x] <
'0') || (StartSpeedStr[x] >
'9'))
11223 TimetableMessage(GiveMessages,
"Train start speed contains invalid characters in '" + TrainInfoStr +
"'");
11228 StartSpeed = StartSpeedStr.ToInt();
11234 TimetableMessage(GiveMessages,
"Train starting speed > 400km/h in '" + TrainInfoStr +
"'. Setting it to 400km/h");
11238 Pos = Remainder.Pos(
';');
11239 AnsiString MaxRunningSpeedStr = Remainder.SubString(1, Pos - 1);
11241 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11242 if(MaxRunningSpeedStr ==
"")
11244 TimetableMessage(GiveMessages,
"Train maximum running speed missing in '" + TrainInfoStr +
"'");
11248 for(
int x = 1; x < MaxRunningSpeedStr.Length() + 1; x++)
11250 if((MaxRunningSpeedStr[x] <
'0') || (MaxRunningSpeedStr[x] >
'9'))
11252 TimetableMessage(GiveMessages,
"Train maximum running speed contains invalid characters in '" + TrainInfoStr +
"'");
11257 MaxRunningSpeed = MaxRunningSpeedStr.ToInt();
11263 TimetableMessage(GiveMessages,
"Train maximum running speed > 400km/h in '" + TrainInfoStr +
"'. Setting it to 400km/h");
11267 if(MaxRunningSpeed < 10)
11270 MaxRunningSpeed = 10;
11273 TimetableMessage(GiveMessages,
"Train maximum running speed can't be less than 10km/h in '" + TrainInfoStr +
"', it will be set to 10km/h");
11277 Pos = Remainder.Pos(
';');
11278 AnsiString MassStr = Remainder.SubString(1, Pos - 1);
11280 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11283 TimetableMessage(GiveMessages,
"Train mass missing in '" + TrainInfoStr +
"'");
11287 for(
int x = 1; x < MassStr.Length() + 1; x++)
11289 if((MassStr[x] <
'0') || (MassStr[x] >
'9'))
11291 TimetableMessage(GiveMessages,
"Train mass contains invalid characters in '" + TrainInfoStr +
"'");
11296 Mass = MassStr.ToInt() * 1000;
11302 TimetableMessage(GiveMessages,
"Train mass > 10,000 tonnes in '" + TrainInfoStr +
"'. Setting it to 10,000 tonnes");
11308 TimetableMessage(GiveMessages,
"Train mass zero in '" + TrainInfoStr +
"'");
11312 Pos = Remainder.Pos(
';');
11313 AnsiString MaxBrakeForceStr = Remainder.SubString(1, Pos - 1);
11315 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11316 if(MaxBrakeForceStr ==
"")
11318 TimetableMessage(GiveMessages,
"Train braking force missing in '" + TrainInfoStr +
"'");
11322 for(
int x = 1; x < (MaxBrakeForceStr.Length() + 1); x++)
11324 if((MaxBrakeForceStr[x] !=
'.') && ((MaxBrakeForceStr[x] <
'0') || (MaxBrakeForceStr[x] >
'9')))
11326 TimetableMessage(GiveMessages,
"Train braking force contains invalid characters in '" + TrainInfoStr +
"'");
11331 double MaxBrakeForce = MaxBrakeForceStr.ToDouble() * 1000;
11334 if((MaxBrakeForce / Mass) > 1)
11336 MaxBrakeForce = Mass;
11339 TimetableMessage(GiveMessages,
"Train braking force too high in '" + TrainInfoStr +
"'. Setting it to the same as the train mass");
11343 if((MaxBrakeForce / Mass) < 0.01)
11345 MaxBrakeForce = Mass * 0.01;
11348 TimetableMessage(GiveMessages,
"Train braking force too low in '" + TrainInfoStr +
"'. Setting it to 1% of the train mass");
11353 MaxBrakeRate = MaxBrakeForce / Mass * 9.81;
11355 AnsiString GrossPowerStr =
"", SignallerSpeedStr =
"";
11357 if(SemiColonCount == 6)
11359 GrossPowerStr = Remainder;
11360 SignallerSpeedStr =
"30";
11364 Pos = Remainder.Pos(
';');
11365 GrossPowerStr = Remainder.SubString(1, Pos - 1);
11366 SignallerSpeedStr = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11369 if(GrossPowerStr ==
"")
11371 TimetableMessage(GiveMessages,
"Train power missing in '" + TrainInfoStr +
"'");
11375 for(
int x = 1; x < GrossPowerStr.Length() + 1; x++)
11377 if((GrossPowerStr[x] <
'0') || (GrossPowerStr[x] >
'9'))
11379 TimetableMessage(GiveMessages,
"Train power contains invalid characters in '" + TrainInfoStr +
"'");
11385 double GrossPower = GrossPowerStr.ToInt() * 1000;
11392 TimetableMessage(GiveMessages,
"Train power > 100,000kW in '" + TrainInfoStr +
"'. Setting it to 100,000kW");
11396 else if(GrossPower == 0)
11401 else if((GrossPower > 0) && (GrossPower < 10000))
11404 GrossPower = 10000;
11406 PowerAtRail = GrossPower * 0.8;
11410 if(SignallerSpeedStr ==
"")
11412 TimetableMessage(GiveMessages,
"Signaller speed not set in '" + TrainInfoStr +
"', either set a value or remove the extra semicolon");
11416 for(
int x = 1; x < SignallerSpeedStr.Length() + 1; x++)
11418 if((SignallerSpeedStr[x] <
'0') || (SignallerSpeedStr[x] >
'9'))
11420 TimetableMessage(GiveMessages,
"Signaller speed contains invalid characters in '" + TrainInfoStr +
"'");
11425 SignallerSpeed = SignallerSpeedStr.ToInt();
11431 TimetableMessage(GiveMessages,
"Signaller speed > 400km/h in '" + TrainInfoStr +
"'. Setting it to 400km/h");
11435 if(SignallerSpeed < 10)
11438 SignallerSpeed = 10;
11441 TimetableMessage(GiveMessages,
"Signaller speed can't be less than 10km/h in '" + TrainInfoStr +
"', it will be set to 10km/h");
11459 if(OneEntry.Length() < 7)
11461 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - should be 'R;m;d;n'");
11465 int SemiColonCount = 0;
11467 for(
int x = 1; x < OneEntry.Length() + 1; x++)
11469 if(OneEntry[x] ==
';')
11474 if(SemiColonCount != 3)
11476 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - should be 'R;m;d;n'");
11480 if((OneEntry[1] !=
'R') || (OneEntry[2] !=
';'))
11482 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - should be 'R;m;d;n'");
11486 AnsiString Remainder = OneEntry.SubString(3, OneEntry.Length() - 2);
11491 Pos = Remainder.Pos(
';');
11492 AnsiString MinutesStr = Remainder.SubString(1, Pos - 1);
11494 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11495 if(MinutesStr ==
"")
11497 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - minute increment segment missing");
11501 if(MinutesStr.Length() > 3)
11504 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - minute value too high, maximum value is 999");
11508 for(
int x = 1; x < MinutesStr.Length() + 1; x++)
11510 if((MinutesStr[x] <
'0') || (MinutesStr[x] >
'9'))
11512 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - non-digit character in minute increment segment");
11517 RearStartOrRepeatMins = MinutesStr.ToInt();
11518 if(RearStartOrRepeatMins == 0)
11520 TimetableMessage(GiveMessages,
"Repeat minute increment is zero in: '" + OneEntry +
"' - can't have a zero value");
11524 Pos = Remainder.Pos(
';');
11525 AnsiString DigitsStr = Remainder.SubString(1, Pos - 1);
11527 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11528 if(DigitsStr ==
"")
11530 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - headcode increment segment missing");
11534 for(
int x = 1; x < DigitsStr.Length() + 1; x++)
11536 if((DigitsStr[x] <
'0') || (DigitsStr[x] >
'9'))
11538 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - non-digit character in headcode increment segment");
11543 if(DigitsStr.Length() > 2)
11545 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - maximum number of digits for headcode increment is 2");
11549 FrontStartOrRepeatDigits = DigitsStr.ToInt();
11563 "' - a repeating service with incrementing digits must have digits as its last two headcode characters");
11567 AnsiString NumberStr = Remainder;
11569 if(NumberStr ==
"")
11571 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - number of repeats missing");
11575 if(NumberStr.Length() > 4)
11578 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - repeat value too high, no timetabled event can exceed 95 hours & 59 minutes");
11582 for(
int x = 1; x < NumberStr.Length() + 1; x++)
11584 if((NumberStr[x] <
'0') || (NumberStr[x] >
'9'))
11587 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - non-digit character in number of repeats");
11592 NumberOfRepeats = NumberStr.ToInt();
11593 if(NumberOfRepeats == 0)
11595 TimetableMessage(GiveMessages,
"Number of repeats is zero in: '" + OneEntry +
"' - if no repeats are needed the repeat should be omitted");
11751 SecondPassMessage(GiveMessages,
"Error in timetable - there appear to be no train services in the timetable, it must contain at least one");
11774 SecondPassMessage(GiveMessages,
"Error in timetable - the following service has no listed events, there must be at least one: " + TDEntry.
HeadCode);
11788 SecondPassMessage(GiveMessages,
"Error in timetable - service must have a start event and at least one other for: " + TDEntry.
HeadCode);
11804 "Error in timetable - a signaller control service can have no more than one item (a repeat) after the start event, see: " +
11816 "Error in timetable - a signaller control service cannot have any other than a repeat after the start event, see: " + TDEntry.
HeadCode);
11843 SecondPassMessage(GiveMessages,
"Error in timetable - finish events Fns-sh and Frh-sh not permitted immediately after an Snt entry for: " +
11854 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11859 SecondPassMessage(GiveMessages,
"Error in timetable - a start event is present that is not the first event for: " + TDEntry.
HeadCode);
11869 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11874 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat is present that is not the last item for: " + TDEntry.
HeadCode);
11884 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11895 SecondPassMessage(GiveMessages,
"Error in timetable - the last item must be either a finish event or a repeat for: " + TDEntry.
HeadCode);
11905 SecondPassMessage(GiveMessages,
"Error in timetable - the last event before the repeat must be a finish for: " + TDEntry.
HeadCode);
11917 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11924 SecondPassMessage(GiveMessages,
"Error in timetable - a finish event must be either the last or last but one for: " + TDEntry.
HeadCode);
11933 SecondPassMessage(GiveMessages,
"Error in timetable - the only event that can follow a finish event is a repeat for: " +
11953 if((AVEntry0.
Command ==
"Snt") || (AVEntry0.
Command ==
"Snt-sh"))
11955 AnsiString LocationName =
"";
11971 SecondPassMessage(GiveMessages,
"Error in timetable - stopped 'Snt' or 'Snt-sh' followed by an illegal event for: " +
11972 TDEntry.
HeadCode +
". The event isn't valid for a stationary train.");
11981 SecondPassMessage(GiveMessages,
"Error in timetable - 'Snt' or 'Snt-sh' event at stop location but start speed not zero for: " +
11990 if(AVEntry0.
Command ==
"Snt-sh")
12004 SecondPassMessage(GiveMessages,
"Error in timetable - unlocated 'Snt' not followed by 'Fer', 'pas' or an arrival for: " +
12020 SecondPassMessage(GiveMessages,
"Error in timetable - 'Sfs', 'Sns', 'Sns-sh' or 'Sns-fsh' followed by an illegal event for: " +
12021 TDEntry.
HeadCode +
". The event isn't valid for a stationary train.");
12032 bool FoundFlag =
false;
12038 for(
unsigned int y = 1; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12050 SecondPassMessage(GiveMessages,
"Error in timetable - no location departure following an 'Sfs', 'Sns', 'Sns-sh'or 'Sns-fsh' event for: " +
12063 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12072 ": an event should have had a location name associated with it but it could not be found");
12078 for(
unsigned int z = y + 1; z <
TrainDataVector.at(x).ActionVector.size(); z++)
12100 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12110 SecondPassMessage(GiveMessages,
"Error in timetable - only a repeat can follow a finish entry for: " + TDEntry.
HeadCode);
12117 if(AVEntry.
Command ==
"F-nshs")
12122 SecondPassMessage(GiveMessages,
"Error in timetable - F-nshs (shuttle link) must be the last event for: " + TDEntry.
HeadCode);
12150 SecondPassMessage(GiveMessages,
"Error in timetable - a jbo event is followed by an illegal event for: " + TDEntry.
HeadCode +
12151 ". The event isn't valid for a stationary train.");
12161 SecondPassMessage(GiveMessages,
"Error in timetable - a train split can't be the last event for: " + TDEntry.
HeadCode);
12169 SecondPassMessage(GiveMessages,
"Error in timetable - a train split is followed by an illegal event for: " + TDEntry.
HeadCode +
12170 ". The event isn't valid for a stationary train.");
12188 SecondPassMessage(GiveMessages,
"Error in timetable - a 'cdt' is followed by an illegal event for: " + TDEntry.
HeadCode +
12189 ". The event isn't valid for a stationary train.");
12199 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure can't be the last event for: " + TDEntry.
HeadCode);
12207 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure is followed by an illegal event for: " +
12208 TDEntry.
HeadCode +
". The event isn't valid for a moving train.");
12226 SecondPassMessage(GiveMessages,
"Error in timetable - a pass time is followed by an illegal event for: " + TDEntry.
HeadCode +
12227 ". The event isn't valid for a moving train.");
12249 bool LastEntryIsAnArrival =
false;
12256 LastEntryIsAnArrival =
false;
12257 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12264 throw Exception(
"Timetable error, TimeLoc times not as initially set for " + TDEntry.
HeadCode);
12266 if(LastEntryIsAnArrival)
12270 LastEntryIsAnArrival =
false;
12276 LastEntryIsAnArrival =
true;
12283 LastEntryIsAnArrival =
true;
12284 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12291 throw Exception(
"Timetable error, TimeLoc times not as initially set for " + TDEntry.
HeadCode);
12293 if(LastEntryIsAnArrival)
12297 LastEntryIsAnArrival =
false;
12303 LastEntryIsAnArrival =
true;
12313 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12321 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival can't be the last event for: " + TDEntry.
HeadCode);
12329 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival is followed by an illegal event for: " + TDEntry.
HeadCode +
12330 ". The event isn't valid for a stationary train.");
12341 SecondPassMessage(GiveMessages,
"Error in timetable - a timed departure can't be the last event for: " + TDEntry.
HeadCode);
12349 SecondPassMessage(GiveMessages,
"Error in timetable - a timed departure is followed by an illegal event for: " + TDEntry.
HeadCode +
12350 ". The event isn't valid for a moving train.");
12364 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12371 throw Exception(
"Timetable error, TimeLoc entry has EventTime not -1 for " + TDEntry.
HeadCode);
12375 throw Exception(
"Timetable error, TimeLoc entry has neither arrival nor departure time set for " + TDEntry.
HeadCode);
12382 throw Exception(
"Timetable error, TimeTimeLoc entry has EventTime not -1 for " + TDEntry.
HeadCode);
12386 throw Exception(
"Timetable error, TimeTimeLoc entry has either arrival or departure time not set for " + TDEntry.
HeadCode);
12395 throw Exception(
"Timetable error, Cmd or PassTime entry has EventTime not set for " + TDEntry.
HeadCode);
12399 throw Exception(
"Timetable error, Cmd or PassTime entry has either arrival or departure time set for " + TDEntry.
HeadCode);
12406 throw Exception(
"Timetable error, Repeat entry has a time set for " + TDEntry.
HeadCode);
12417 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12432 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure has a later arrival than departure time for: " +
12440 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure has too early an arrival time for: " +
12455 SecondPassMessage(GiveMessages,
"Error in timetable - a timed location event has a time that is too early for: " + TDEntry.
HeadCode);
12467 SecondPassMessage(GiveMessages,
"Error in timetable - a timed location event has a time that is too early for: " + TDEntry.
HeadCode);
12479 SecondPassMessage(GiveMessages,
"Error in timetable - a train event has a time that is set too early for: " + TDEntry.
HeadCode +
12480 ", may be before timetable start time");
12491 AnsiString LastLocationName =
"";
12495 bool LastEntryIsAnArrival =
false;
12500 LastEntryIsAnArrival =
false;
12501 LastLocationName =
TrainDataVector.at(x).ActionVector.at(0).LocationName;
12502 if(LastLocationName !=
"")
12504 throw Exception(
"Timetable error, moving Snt entry has LocationName set for " + TDEntry.
HeadCode);
12506 for(
unsigned int y = 1; y <
TrainDataVector.at(x).ActionVector.size();
12519 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12531 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12543 ShowMessage(
"Two or more locations are the same without a change of direction between them. Please correct if this is an error.\n\nThis warning will not be shown again.");
12552 LastEntryIsAnArrival =
false;
12556 if(LastEntryIsAnArrival && (AVEntry.
LocationName != LastLocationName))
12559 "Error in timetable - a location event for a timed departure is different from the arrival location for: " + TDEntry.
HeadCode);
12564 else if(!LastEntryIsAnArrival && (AVEntry.
LocationName == LastLocationName))
12567 "Error in timetable - a location event for a timed arrival is the same as the earlier departure location for: " + TDEntry.
HeadCode);
12573 LastEntryIsAnArrival = !LastEntryIsAnArrival;
12579 LastEntryIsAnArrival =
true;
12580 LastLocationName =
TrainDataVector.at(x).ActionVector.at(0).LocationName;
12581 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12593 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12605 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12617 ShowMessage(
"Two or more locations are the same without a change of direction between them. Please correct if this is an error.\n\nThis warning will not be shown again.");
12626 LastEntryIsAnArrival =
false;
12630 if(LastEntryIsAnArrival && (AVEntry.
LocationName != LastLocationName))
12633 "Error in timetable - a location event for a timed departure is different from the arrival location for: " + TDEntry.
HeadCode);
12641 "A location event for a timed arrival is the same as the earlier departure location for: " + TDEntry.
HeadCode +
". Please correct if this is an error.\n\nThis warning will not be shown again.");
12648 LastEntryIsAnArrival = !LastEntryIsAnArrival;
12656 AnsiString LocationNameToBeChecked =
"";
12661 unsigned int y = 0;
12676 LocationNameToBeChecked = TDEntry.
ActionVector.at(y).LocationName;
12677 for(
unsigned int z = y; z < TDEntry.
ActionVector.size(); z++)
12695 for(
unsigned int a = z; a < TDEntry.
ActionVector.size(); a++)
12703 ShowMessage(
"Two or more locations are the same without a change of direction between them. Please correct if this is an error.\n\nThis warning will not be shown again.");
12722 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12727 throw Exception(
"Error, non- 'Snt', 'Fer' or Repeat entry doesn't have a location name set for " + TDEntry.
HeadCode);
12729 AnsiString LocName =
"";
12735 throw Exception(
"Error, 'Snt' entry at a stop location doesn't have a location name set for " + TDEntry.
HeadCode);
12742 throw Exception(
"Error, 'Snt' unlocated entry has a location name set for " + TDEntry.
HeadCode);
12765 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12790 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12812 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12834 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12853 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12856 if((AVEntry.
Command ==
"Sns-sh") || (AVEntry.
Command ==
"Snt-sh"))
12871 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12876 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has FormatType unset for: " + TDEntry.
HeadCode);
12880 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has SequenceType unset for: " + TDEntry.
HeadCode);
12884 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has LocationType unset for: " + TDEntry.
HeadCode);
12888 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has ShuttleLinkType unset for: " + TDEntry.
HeadCode);
12927 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12929 AnsiString LocName =
TrainDataVector.at(x).ActionVector.at(y).LocationName;
12935 SecondPassMessage(GiveMessages,
"Error in timetable - continuation names (" + LocName +
") must not be included, see service " + HC);
12948 int IncMinutes = 0;
12958 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12964 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat time exceeds 95h 59m, see service " + HC);
12970 if((
double)
TrainDataVector.at(x).ActionVector.at(y).ArrivalTime > -1)
12975 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat entry time exceeds 95h 59m, see service " + HC);
12981 if((
double)
TrainDataVector.at(x).ActionVector.at(y).DepartureTime > -1)
12986 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat entry time exceeds 95h 59m, see service " + HC);
12999 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13025 (AVEntry.
Command ==
"Fns-sh") || (AVEntry.
Command ==
"F-nshs"));
13033 if(HeadCode.Length() > 4)
13035 HeadCode = HeadCode.SubString(HeadCode.Length() - 3, 4);
13046 int ForwardCount = 0;
13047 int ReverseCount = 0;
13049 if(MainHeadCode == SecondHeadCode)
13051 SecondPassMessage(GiveMessages,
"Error in timetable - Service " + MainHeadCode +
" has an event that references itself");
13060 if(TDEntry.
HeadCode == MainHeadCode)
13062 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13077 if(ForwardCount == 0)
13080 throw Exception(
"Error, ForwardCount == 0 in CheckForDuplicateCrossReferences after called with found values");
13082 if(ForwardCount > 2)
13085 SecondPassMessage(GiveMessages,
"Error in timetable - found more than two references to " + SecondHeadCode +
" from a train whose headcode is " +
13086 MainHeadCode +
". Check the service cross references from each service, and check whether one or other service is listed twice or more.");
13095 if(TDEntry.
HeadCode == SecondHeadCode)
13097 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13112 if(ReverseCount == 0)
13114 SecondPassMessage(GiveMessages,
"Error in timetable - cross reference missing in either " + MainHeadCode +
" or " + SecondHeadCode);
13119 if(ReverseCount > 2)
13122 SecondPassMessage(GiveMessages,
"Error in timetable - found more than two references to " + MainHeadCode +
" from a train whose headcode is " +
13123 SecondHeadCode +
". Check the service cross references from each service, and check whether one or other service is listed twice or more.");
13128 if(ForwardCount != ReverseCount)
13130 SecondPassMessage(GiveMessages,
"Error in timetable - " + MainHeadCode +
" has a different number of references to " + SecondHeadCode +
13131 " than the other way round");
13162 int ForwardCount = 0;
13163 int ReverseCount = 0;
13164 unsigned int ForwardTDVectorNumber, ReverseTDVectorNumber;
13173 if(TDEntry.
HeadCode == MainHeadCode)
13175 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13178 if(!Shuttle && (AVEntry.
Command !=
"Sns-sh") && (AVEntry.
Command !=
"Snt-sh") && (AVEntry.
Command !=
"Fns-sh") && (AVEntry.
Command !=
"Frh-sh"))
13183 ForwardEntryPtr = &AVEntry;
13185 ForwardTDVectorNumber = x;
13188 else if(Shuttle && ((AVEntry.
Command ==
"Sns-sh") || (AVEntry.
Command ==
"Snt-sh") || (AVEntry.
Command ==
"Fns-sh") ||
13189 (AVEntry.
Command ==
"Frh-sh")))
13194 ForwardEntryPtr = &AVEntry;
13196 ForwardTDVectorNumber = x;
13202 if(ForwardCount == 0)
13205 throw Exception(
"Error, ForwardCount == 0 in CheckCrossReferencesAndSetData after called with found values");
13207 if(ForwardCount > 1)
13209 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + OtherHeadCode +
" from a train whose headcode is " +
13219 if(TDEntry.
HeadCode == OtherHeadCode)
13221 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13224 if(!Shuttle && (AVEntry.
Command !=
"Sns-sh") && (AVEntry.
Command !=
"Snt-sh") && (AVEntry.
Command !=
"Fns-sh") && (AVEntry.
Command !=
"Frh-sh"))
13230 ReverseEntryPtr = &AVEntry;
13231 ReverseTDVectorNumber = x;
13234 else if(Shuttle && ((AVEntry.
Command ==
"Sns-sh") || (AVEntry.
Command ==
"Snt-sh") || (AVEntry.
Command ==
"Fns-sh") || (AVEntry.
Command ==
"Frh-sh")))
13240 ReverseEntryPtr = &AVEntry;
13241 ReverseTDVectorNumber = x;
13248 if(ReverseCount == 0)
13250 SecondPassMessage(GiveMessages,
"Error in timetable - cross reference missing in either " + MainHeadCode +
" or " + OtherHeadCode);
13255 if(ReverseCount > 1)
13257 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + MainHeadCode +
" from a train whose headcode is " +
13264 bool ForwardShuttleStart = ((ForwardEntryPtr->Command ==
"Sns-sh") || (ForwardEntryPtr->Command ==
"Snt-sh"));
13265 bool ForwardShuttleFinish = ((ForwardEntryPtr->Command ==
"Fns-sh") || (ForwardEntryPtr->Command ==
"Frh-sh"));
13266 bool ReverseShuttleStart = ((ReverseEntryPtr->
Command ==
"Sns-sh") || (ReverseEntryPtr->
Command ==
"Snt-sh"));
13267 bool ReverseShuttleFinish = ((ReverseEntryPtr->
Command ==
"Fns-sh") || (ReverseEntryPtr->
Command ==
"Frh-sh"));
13271 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle train " + MainHeadCode +
" does not have a repeat");
13278 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle train " + OtherHeadCode +
" does not have a repeat");
13283 if(ForwardEntryPtr->LocationName ==
"")
13285 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + OtherHeadCode +
13286 ". One or other service does not have a location set");
13293 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + OtherHeadCode +
13294 ". One or other service does not have a location set");
13299 if(ForwardEntryPtr->LocationName != ReverseEntryPtr->
LocationName)
13301 SecondPassMessage(GiveMessages,
"Error in timetable - cross referenced train " + OtherHeadCode +
13302 " is at a different location to the referencing train " + MainHeadCode);
13310 if(ForwardEntryPtr->EventTime != ReverseEntryPtr->
EventTime)
13312 SecondPassMessage(GiveMessages,
"Error in timetable - cross referenced train " + OtherHeadCode +
13313 " has a different event time to the referencing train " + MainHeadCode);
13321 if(ForwardShuttleStart && ReverseShuttleFinish)
13326 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle service " + MainHeadCode +
13327 " first repeat restart time not consistent with finish service " + OtherHeadCode);
13333 if((ReverseEntryPtr->
Command ==
"Sfs") || (ReverseEntryPtr->
Command ==
"Sns"))
13336 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
13338 SecondPassMessage(GiveMessages,
"Error in timetable - an 'Sfs' or 'Sns' event (" + OtherHeadCode +
13339 ") appears in the same sequence as the corresponding linked event " + MainHeadCode);
13345 if(ReverseEntryPtr->
Command ==
"Fjo")
13348 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
13350 SecondPassMessage(GiveMessages,
"Error in timetable - an 'Fjo' event (" + OtherHeadCode +
13351 ") appears in the same sequence as the corresponding linked event " + MainHeadCode);
13357 if(ReverseEntryPtr->
Command ==
"Fns")
13360 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
13362 SecondPassMessage(GiveMessages,
"Error in timetable - an 'Fns' event (" + OtherHeadCode +
13363 ") appears in the same sequence as the corresponding linked event " + MainHeadCode);
13369 if(ForwardEntryPtr->Command ==
"Sfs")
13371 if((ReverseEntryPtr->
Command !=
"fsp") && (ReverseEntryPtr->
Command !=
"rsp"))
13374 "Error in timetable - unable to find a corresponding split train event for the train that starts from a split whose headcode is " +
13381 if((ForwardEntryPtr->Command ==
"fsp") || (ForwardEntryPtr->Command ==
"rsp"))
13383 if(ReverseEntryPtr->
Command !=
"Sfs")
13385 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Sfs' event for the train split whose headcode is " +
13395 SecondPassMessage(GiveMessages,
"Error in timetable - can't find timetabled location '" + ForwardEntryPtr->LocationName +
"' in railway - perhaps there are concourses without platforms?");
13402 SecondPassMessage(GiveMessages,
"Error in timetable - can't find any named location elements at '" + ForwardEntryPtr->LocationName +
"' - perhaps there are concourses without platforms?");
13409 SecondPassMessage(GiveMessages,
"Error in timetable - location too short to split a train at " + ForwardEntryPtr->LocationName);
13414 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13425 if(ForwardEntryPtr->Command ==
"Sns")
13427 if(ReverseEntryPtr->
Command !=
"Fns")
13429 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Fns' event for the 'Sns' train whose headcode is " +
13430 MainHeadCode +
" and is formed from a service with headcode " + OtherHeadCode);
13436 if(ForwardEntryPtr->Command ==
"Fns")
13438 if(ReverseEntryPtr->
Command !=
"Sns")
13440 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Sns' event for the train whose headcode is " + MainHeadCode +
13441 " and forms a new service with headcode " + OtherHeadCode);
13448 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13459 if(ForwardEntryPtr->Command ==
"jbo")
13461 if(ReverseEntryPtr->
Command !=
"Fjo")
13463 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Fjo' event for the train whose headcode is " + MainHeadCode +
13464 " and is joined by a train with headcode " + OtherHeadCode);
13470 if(ForwardEntryPtr->Command ==
"Fjo")
13472 if(ReverseEntryPtr->
Command !=
"jbo")
13474 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'jbo' event for the train whose headcode is " + MainHeadCode +
13475 " and joins a train with headcode " + OtherHeadCode);
13482 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13492 if(ForwardShuttleStart)
13495 if(!ReverseShuttleFinish)
13498 SecondPassMessage(GiveMessages,
"Error in timetable - incorrect shuttle link to train whose headcode is " + MainHeadCode +
13499 " from train whose headcode is " + OtherHeadCode +
", has to be Fns-sh, Frh-sh");
13505 if(ReverseShuttleStart)
13508 if(!ForwardShuttleFinish)
13511 SecondPassMessage(GiveMessages,
"Error in timetable - incorrect shuttle link to train whose headcode is " + OtherHeadCode +
13512 " from train whose headcode is " + MainHeadCode +
", has to be Fns-sh, Frh-sh");
13519 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13531 bool MainRepeat =
false, OtherRepeat =
false;
13541 OtherRepeat =
true;
13544 if((MainRepeat && !OtherRepeat) || (!MainRepeat && OtherRepeat))
13546 SecondPassMessage(GiveMessages,
"Error in timetable - only one repeat is provided for the train whose headcode is " + MainHeadCode +
13547 " and the associated train with headcode " + OtherHeadCode);
13552 if(MainRepeat && OtherRepeat)
13558 SecondPassMessage(GiveMessages,
"Error in timetable - repeat items don't correspond for the train whose headcode is " + MainHeadCode +
13559 " and the associated train with headcode " + OtherHeadCode);
13581 while(Input[1] ==
' ')
13583 if(Input.Length() > 1)
13585 Input = Input.SubString(2, Input.Length() - 1);
13599 while(Input[Input.Length()] ==
' ')
13601 if(Input.Length() > 1)
13603 Input = Input.SubString(1, Input.Length() - 1);
13613 AnsiString Output =
"";
13614 bool DelimiterFound =
false;
13616 for(
int x = 1; x < Input.Length() + 1; x++)
13620 if(Input[x] ==
' ')
13625 if((Input[x] !=
',') && (Input[x] !=
';'))
13627 DelimiterFound =
false;
13628 Output = Output + Input[x];
13632 DelimiterFound =
true;
13633 Output = Output + Input[x];
13645 DelimiterFound =
false;
13646 for(
int x = Input.Length(); x > 0; x--)
13650 if(Input[x] ==
' ')
13655 if((Input[x] !=
',') && (Input[x] !=
';'))
13657 DelimiterFound =
false;
13658 Output = AnsiString(Input[x]) + Output;
13662 DelimiterFound =
true;
13663 Output = AnsiString(Input[x]) + Output;
13683 if((AVEntry0.
Command !=
"Snt") && (AVEntry0.
Command !=
"Snt-sh"))
13685 throw Exception(
"Error, first entry not 'Snt' or 'Snt-sh' in IsSNTEntryLocated");
13697 LocationName = LocRear;
13701 LocationName = LocFront;
13703 if(LocationName ==
"")
13729 AnsiString TimeLocLocationName;
13730 bool FoundFlag =
false;
13732 for(
unsigned int y = 0; y < TDEntry.
ActionVector.size(); y++)
13747 if(TimeLocLocationName == LocationName)
13764 int RearPosition = 0, FrontPosition = 0, RearExitPos = 0;
13767 if(RearPosition < 0)
13774 if(FrontPosition < 0)
13785 for(
int x = 0; x < 4; x++)
13787 if(RearTrackElement.
Conn[x] == FrontPosition)
13802 TimetableMessage(GiveMessages,
"Front of train attempting to start on a continuation at: " + FrontElementStr);
13809 TimetableMessage(GiveMessages,
"Train attempting to start on a level crossing at: " + FrontElementStr);
13815 TimetableMessage(GiveMessages,
"Train attempting to start on a level crossing at: " + RearElementStr);
13820 if((RearType ==
Points) && (RearExitPos == 3))
13822 TimetableMessage(GiveMessages,
"Front of train attempting to start on element connected to diverging points at: " + RearElementStr);
13828 TimetableMessage(GiveMessages,
"Rear of train attempting to start on element connected to diverging points at: " + FrontElementStr);
13843 AnsiString(RearExitPos));
13854 int FrontPosition = RearTrackElement.
Conn[RearExitPos];
13856 int FrontEntryPos = RearTrackElement.
ConnLinkPos[RearExitPos];
13859 AnsiString RearName, FrontName;
13875 FrontName = FrontTrackElement.
ElementID;
13878 int LockedVectorNumber;
14029 "," + AnsiString(IncDigits));
14032 throw Exception(
"Error, last 2 characters not both digits and IncDigits > 0 in GetRepeatHeadCode");
14037 return(BaseHeadCode);
14039 int BaseDigits = BaseHeadCode.SubString(3, 2).ToInt();
14040 int NextRepeatDigits = BaseDigits + (IncDigits * RepeatNumber);
14042 while(NextRepeatDigits >= 100)
14044 NextRepeatDigits -= 100;
14046 AnsiString NextRepeatDigitsStr = AnsiString(NextRepeatDigits);
14048 if(NextRepeatDigitsStr.Length() < 2)
14050 NextRepeatDigitsStr = AnsiString(
'0') + NextRepeatDigitsStr;
14052 AnsiString NextRepeatHeadCode = BaseHeadCode.SubString(1, 2) + NextRepeatDigitsStr;
14055 return(NextRepeatHeadCode);
14063 AnsiString(RepeatNumber) +
"," + AnsiString(IncMinutes));
14064 TDateTime NextRepeatTime = BasicTime + TDateTime(((
double)(RepeatNumber * IncMinutes)) / 1440.0);
14067 return(NextRepeatTime);
14076 AnsiString(
double(ReverseEventTime)) +
"," + AnsiString(RepeatMinutes));
14077 int ForwardSecs = int(
double(ForwardEventTime) * 86400);
14078 int ReverseSecs = int(
double(ReverseEventTime) * 86400);
14079 int RepeatSecs = RepeatMinutes * 60;
14081 if((ForwardSecs > (ReverseSecs - RepeatSecs + 10)) || (ForwardSecs < (ReverseSecs - RepeatSecs - 10)))
14099 NonRepeatingHeadCode);
14100 int ForwardCount = 0;
14101 int ReverseCount = 0;
14102 unsigned int ForwardTDVectorNumber, ReverseTDVectorNumber;
14112 if(TDEntry.
HeadCode == MainHeadCode)
14114 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
14120 ForwardEntryPtr = &AVEntry;
14122 ForwardTDVectorNumber = x;
14127 if(ForwardCount == 0)
14130 throw Exception(
"Error, ForwardCount == 0 in CheckNonRepeatingShuttleLinksAndSetData after called with found values");
14132 if(ForwardCount > 1)
14134 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + NonRepeatingHeadCode +
" from a train whose headcode is " +
14144 if(TDEntry.
HeadCode == NonRepeatingHeadCode)
14146 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
14153 ReverseEntryPtr = &AVEntry;
14154 ReverseTDVectorNumber = x;
14160 if(ReverseCount == 0)
14162 SecondPassMessage(GiveMessages,
"Error in timetable - cross reference missing in either " + MainHeadCode +
" or " + NonRepeatingHeadCode);
14167 if(ReverseCount > 1)
14169 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + MainHeadCode +
" from a train whose headcode is " +
14170 NonRepeatingHeadCode);
14175 if(((ForwardEntryPtr->Command ==
"F-nshs") || (ForwardEntryPtr->Command ==
"Sns-fsh")) && (MainTrainDataPtr->
ActionVector.back().FormatType ==
Repeat))
14177 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle connecting train " + MainHeadCode +
" shouldn't have a repeat");
14182 if((ForwardEntryPtr->Command !=
"F-nshs") && (ForwardEntryPtr->Command !=
"Sns-fsh") && (MainTrainDataPtr->
ActionVector.back().FormatType !=
Repeat))
14184 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle train " + MainHeadCode +
" does not have a repeat item");
14189 if(ForwardEntryPtr->LocationName ==
"")
14191 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + NonRepeatingHeadCode +
14192 ". One or other service does not have a location set");
14199 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + NonRepeatingHeadCode +
14200 ". One or other service does not have a location set");
14205 if(ForwardEntryPtr->LocationName != ReverseEntryPtr->
LocationName)
14207 SecondPassMessage(GiveMessages,
"Error in timetable - cross referenced train " + NonRepeatingHeadCode +
14208 " is at a different location to the referencing train " + MainHeadCode);
14213 if(ForwardEntryPtr->Command ==
"F-nshs")
14216 if(ForwardEntryPtr->EventTime != ReverseEntryPtr->
EventTime)
14218 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle in-link service " + MainHeadCode +
14219 " finish time not consistent with start time of shuttle service " + NonRepeatingHeadCode);
14225 if(ForwardEntryPtr->Command ==
"Fns-sh")
14229 MainTrainDataPtr->
ActionVector.back().RearStartOrRepeatMins, MainTrainDataPtr->
ActionVector.back().NumberOfRepeats))
14231 SecondPassMessage(GiveMessages,
"Error in timetable - service " + NonRepeatingHeadCode +
", which links out from shuttle service " + MainHeadCode +
14232 ", has the wrong start time. It should correspond to the finish time of the last shuttle.");
14238 if((ForwardEntryPtr->Command ==
"F-nshs") || (ForwardEntryPtr->Command ==
"Sns-fsh"))
14241 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
14243 SecondPassMessage(GiveMessages,
"Error in timetable - the non repeating link service " + NonRepeatingHeadCode +
14244 " appears in the same sequence as the corresponding shuttle service " + MainHeadCode);
14262 if(ForwardEntryPtr->Command ==
"Sns-sh")
14264 if(ReverseEntryPtr->
Command !=
"F-nshs")
14266 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'F-nshs' event for the 'Sns-sh' train whose headcode is " +
14267 MainHeadCode +
" and is a new shuttle service formed from the service with headcode " + NonRepeatingHeadCode);
14273 if(ForwardEntryPtr->Command ==
"F-nshs")
14275 if(ReverseEntryPtr->
Command !=
"Sns-sh")
14277 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Sns-sh' event for the 'F-nshs' train whose headcode is " +
14278 MainHeadCode +
" and forms a new shuttle service with headcode " + NonRepeatingHeadCode);
14285 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
14296 if(ForwardEntryPtr->Command ==
"Sns-fsh")
14298 if(ReverseEntryPtr->
Command !=
"Fns-sh")
14301 "Error in timetable - unable to find a corresponding 'Fns-sh' event for the 'Sns-fsh' non-shuttle service whose headcode is " + MainHeadCode +
14302 " formed from a shuttle service with headcode " + NonRepeatingHeadCode);
14308 if(ForwardEntryPtr->Command ==
"Fns-sh")
14310 if(ReverseEntryPtr->
Command !=
"Sns-fsh")
14313 "Error in timetable - unable to find a corresponding 'Sns-fsh' event for the 'Fns-sh' shuttle service whose headcode is " + MainHeadCode +
14314 " and forms a new non-shuttle service with headcode " + NonRepeatingHeadCode);
14321 ForwardEntryPtr->NonRepeatingShuttleLinkEntryPtr = OtherTrainDataPtr;
14345 +
"," + AnsiString(
double(ReverseEventTime)) +
"," + AnsiString(RepeatMinutes) +
"," + AnsiString(RepeatNumber));
14346 int ForwardSecs = int(
double(ForwardEventTime) * 86400);
14347 int ReverseSecs = int(
double(ReverseEventTime) * 86400);
14348 int RepeatSecs = RepeatMinutes * RepeatNumber * 60;
14350 if((ReverseSecs > (ForwardSecs + RepeatSecs + 10)) || (ReverseSecs < (ForwardSecs + RepeatSecs - 10)))
14374 throw Exception(
"Error - last entry in " + TDEntryPtr->
HeadCode +
" service is not a repeat - should have already found this error");
14377 AnsiString OriginalHeadCode = TDEntryPtr->
HeadCode;
14378 AnsiString LastActionCommand = (TDEntryPtr->
ActionVector.end() - 2)->Command;
14380 if((LastActionCommand !=
"Fns") && (LastActionCommand !=
"Fns-sh") && (LastActionCommand !=
"Frh-sh"))
14382 SecondPassMessage(GiveMessages,
"Error in timetable - last event in shuttle service " + TDEntryPtr->
HeadCode +
" is not 'Fns', 'Fns-sh' or 'Frh-sh'");
14387 while(LastActionCommand ==
"Fns")
14389 TDEntryPtr = (TDEntryPtr->
ActionVector.end() - 2)->LinkedTrainEntryPtr;
14390 LastActionCommand = (TDEntryPtr->
ActionVector.end() - 2)->Command;
14391 if((LastActionCommand !=
"Fns") && (LastActionCommand !=
"Fns-sh") && (LastActionCommand !=
"Frh-sh"))
14394 "Error in timetable - last event in a continuation shuttle service (i.e links back to a shuttle) whose headcode is " + TDEntryPtr->
HeadCode +
14395 " is not 'Fns', 'Fns-sh' or 'Frh-sh'");
14402 if((TDEntryPtr->
ActionVector.end() - 2)->LinkedTrainEntryPtr != ShuttleStartAddress)
14405 " is a shuttle finish, but it doesn't link back to the start of the original shuttle starting service " + OriginalHeadCode +
14406 ". The linking of two or more shuttles is not permitted.");
14426 ShowMessage(Message);
14444 ShowMessage(Message);
14482 AnsiString(ActionEventType) +
"," + LocationID);
14483 AnsiString BaseLog =
"", Prefix =
"", ErrorLog =
"", WarningStr =
"";
14485 Prefix =
" ERROR: ";
14488 Prefix =
" HELD: ";
14489 ErrorLog =
" can't enter railway, train obstructing entry position ";
14490 WarningStr =
" can't enter railway, train obstructing entry position ";
14495 Prefix =
" HELD: ";
14496 ErrorLog =
" can't be created, train obstructing ";
14497 WarningStr =
" can't be created, train obstructing ";
14502 Prefix =
" HELD: ";
14503 ErrorLog =
" can't be created on a locked route at ";
14504 WarningStr =
" can't be created on a locked route at ";
14509 Prefix =
" HELD: ";
14510 ErrorLog =
" can't enter on a locked route at ";
14511 WarningStr =
" can't enter on a locked route at ";
14516 Prefix =
" HELD: ";
14517 ErrorLog =
" can't be created, diverging points at ";
14518 WarningStr =
" can't be created, diverging points at ";
14523 ErrorLog =
" left railway unexpectedly at ";
14528 ErrorLog =
" left railway at an incorrect exit at ";
14533 ErrorLog =
" failed to split - location too short at ";
14534 WarningStr =
" failed to split, location too short at ";
14539 Prefix =
" HELD: ";
14540 ErrorLog =
" unable to split - other train obstructing at ";
14541 WarningStr =
" unable to split - other train obstructing at ";
14546 ErrorLog =
" stopped at buffers unexpectedly at position ";
14550 ErrorLog =
" failed to stop at ";
14555 ErrorLog =
" failed to split at ";
14560 ErrorLog =
" failed to be joined by other train at ";
14565 ErrorLog =
" failed to join other train at ";
14570 ErrorLog =
" failed to terminate at ";
14575 ErrorLog =
" failed to form new service at ";
14580 ErrorLog =
" failed to exit railway ";
14585 ErrorLog =
" failed to change direction at ";
14590 ErrorLog =
" failed to pass ";
14595 ErrorLog =
" facing buffers and unable to start at ";
14599 ErrorLog =
" DERAILED at position ";
14600 Prefix =
" DERAILMENT: ";
14605 ErrorLog =
" CRASHED INTO BUFFERS at ";
14606 Prefix =
" CRASH: ";
14611 ErrorLog =
" CRASHED INTO ROAD TRAFFIC AT A LEVEL CROSSING at ";
14612 Prefix =
" CRASH: ";
14617 ErrorLog =
" CRASHED INTO " + OtherHeadCode +
" at position ";
14618 Prefix =
" CRASH: ";
14622 else if(ActionEventType ==
FailSPAD)
14624 ErrorLog =
" PASSED SIGNAL AT DANGER at position ";
14625 Prefix =
" SPAD: ";
14630 ErrorLog =
"Signals reset ahead of train, route cancelled at position ";
14631 Prefix =
" SPAD RISK: ";
14636 ErrorLog =
" forced a route cancellation by occupying it incorrectly at ";
14640 Prefix =
" WARNING: ";
14641 ErrorLog =
" waiting to join " + OtherHeadCode +
" at ";
14642 WarningStr =
" waiting to join " + OtherHeadCode +
" at ";
14647 Prefix =
" WARNING: ";
14648 ErrorLog =
" waiting to be joined by " + OtherHeadCode +
" at ";
14649 WarningStr =
" waiting to be joined by " + OtherHeadCode +
" at ";
14688 std::ofstream OutFile(
"TrainData.csv");
14692 ShowMessage(
"Output file TrainData.csv failed to open");
14699 OutFile <<
"HeadCode" <<
',' <<
"Description" <<
',' <<
"StartSpeed" <<
',' <<
"MaxRunningSpeed" <<
',' <<
"NumberOfTrains" <<
'\n' <<
'\n';
14704 OutFile <<
',' <<
"FormatType" <<
',' <<
"EventTime" <<
',' <<
"ArrivalTime" <<
',' <<
"DepartureTime" <<
',' <<
"LocationName" <<
',' <<
"Command" <<
14705 ',' <<
"OtherHeadCode" <<
',' <<
"LinkedTrainEntryPtr" <<
',' <<
"RearStartOrRepeatMins" <<
',' <<
"FrontStartOrRepeatDigits" <<
',' <<
14706 "RepeatNumber" <<
'\n' <<
'\n';
14707 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
14710 AnsiString TimetableEntryTypeStr;
14716 TimetableEntryTypeStr =
"NoFormat";
14722 TimetableEntryTypeStr =
"TimeLoc";
14728 TimetableEntryTypeStr =
"TimeTimeLoc";
14734 TimetableEntryTypeStr =
"TimeCmd";
14740 TimetableEntryTypeStr =
"StartNew";
14746 TimetableEntryTypeStr =
"TimeCmdHeadCode";
14752 TimetableEntryTypeStr =
"FinRemHere";
14758 TimetableEntryTypeStr =
"FNSShuttle";
14764 TimetableEntryTypeStr =
"SNTShuttle";
14770 TimetableEntryTypeStr =
"SNSShuttle";
14776 TimetableEntryTypeStr =
"SNSNonRepeatFromShuttle";
14782 TimetableEntryTypeStr =
"FSHNewService";
14788 TimetableEntryTypeStr =
"Repeat";
14794 TimetableEntryTypeStr =
"Default";
14805 OutFile <<
',' <<
',' <<
"Mass" <<
',' <<
"MaxBrakeRate" <<
',' <<
"PowerAtRail" <<
',' <<
"TrainID" <<
',' <<
"RunningEntry" <<
'\n' <<
'\n';
14806 for(
unsigned int y = 0; y <
TrainDataVector.at(x).TrainOperatingDataVector.size(); y++)
14809 AnsiString RunningEntryStr;
14815 RunningEntryStr =
"NotStarted";
14821 RunningEntryStr =
"Running";
14827 RunningEntryStr =
"Exited";
14831 OutFile <<
',' <<
',' << TOD.
TrainID <<
',' << RunningEntryStr.c_str() <<
',' <<
'\n';
14848 ShowMessage(Message);
14849 BaseTime = TDateTime::CurrentDateTime();
14863 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
14876 TTrain *NewTrain =
new TTrain(1, 0, 0,
"", 0, 1, 0, 0, 0, (
TTrainMode)0, 0, 0, 0, 0, 0);
14878 for(
int x = 0; x < NumberOfTrains; x++)
14880 *NewTrain =
TTrain(2, 0, 0,
"", 0, 1, 0, 0, 0, (
TTrainMode)0, 0, 0, 0, 0, 0);
14900 int NumberOfTrains;
14907 for(
int x = 0; x < NumberOfTrains; x++)
14944 for(
int x = 0; x < LockedRouteVectorSize; x++)
14951 LockedRouteObject.
LockStartTime = TDateTime(LockStartTimeDouble);
14962 int LockedRouteVectorSize;
14969 for(
int x = 0; x < LockedRouteVectorSize; x++)
15027 for(
int x = 0; x < ContinuationAutoSigVectorSize; x++)
15035 ContinuationAutoSigObject.
PassoutTime = TDateTime(PassoutTimeDouble);
15046 int ContinuationAutoSigVectorSize;
15053 for(
int x = 0; x < ContinuationAutoSigVectorSize; x++)
15123 if(AVFirstEntry.
Command ==
"Snt")
15147 CTEMMP.second = CTEEntry;
15154 throw Exception(
"Error, Last ActionVectorEntry not a repeat in BuildContinuationTrainExpectationMultiMap");
15162 CTEMMP.second = CTEEntry;
15183 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
15200 if((VecPos < 0) || (VecPos >= (
int)
TrainVector.size()))
15202 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrainVector.size()) +
", VecPos: " + AnsiString(VecPos) +
" in TrainVectorAt");
15213 AnsiString RetStr =
"", PartStr =
"";
15328 AnsiString TTFileName = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
15332 TTFileName = CurDir +
"\\Formatted timetables\\Timetable " + TTFileName +
"; " + RailwayTitle +
"; " + TimetableTitle +
".csv";
15334 AnsiString ShortTTName =
"";
15336 for(
int x = TTFileName.Length(); x > 0; x--)
15338 if(TTFileName[x] ==
'\\')
15340 ShortTTName = TTFileName.SubString(x + 1, TTFileName.Length() - x - 4);
15345 ShowMessage(
"Creates two timetables named " + ShortTTName +
15346 " in the 'Formatted timetables' folder, one in service order in '.csv' format, and one in chronological order in '.txt' format");
15348 Screen->Cursor = TCursor(-11);
15350 AnsiString FormatNoDPStr =
"#######0";
15351 AnsiString TableTitle =
"", TimetableTimeStr =
"", MassStr =
"", PowerStr =
"", BrakeStr =
"", MaxSpeedStr =
"", FirstHeadCode =
"", Header =
"";
15354 TableTitle =
"Railway: " + RailwayTitle +
"; Timetable: " + TimetableTitle +
"; Start time: " + TimetableTimeStr;
15361 MassStr =
"", PowerStr =
"", BrakeStr =
"", MaxSpeedStr =
"";
15363 if(TrainDataEntry.
Mass > 0)
15365 MassStr =
"; Mass " + AnsiString::FormatFloat(FormatNoDPStr, ((
double)TrainDataEntry.
Mass) / 1000) +
"Te; ";
15369 PowerStr =
"Power " + AnsiString::FormatFloat(FormatNoDPStr, TrainDataEntry.
PowerAtRail / 1000 / 0.8) +
"kW; ";
15373 BrakeStr =
"Brake force " + AnsiString::FormatFloat(FormatNoDPStr, (TrainDataEntry.
MaxBrakeRate * TrainDataEntry.
Mass / 9810)) +
"Te; ";
15377 MaxSpeedStr =
"Maximum speed " + AnsiString::FormatFloat(FormatNoDPStr, TrainDataEntry.
MaxRunningSpeed) +
" km/h";
15379 FirstHeadCode = TrainDataEntry.
HeadCode;
15380 int IncDigits = 0, IncMinutes = 0;
15382 if(!ActionVector.empty())
15384 if(ActionVector.at(ActionVector.size() - 1).FormatType ==
Repeat)
15386 IncDigits = ActionVector.at(ActionVector.size() - 1).FrontStartOrRepeatDigits;
15387 IncMinutes = ActionVector.at(ActionVector.size() - 1).RearStartOrRepeatMins;
15395 if((TrainDataEntry.
Description !=
"") && (MassStr !=
""))
15397 OneTTLine.
Header = TrainDataEntry.
Description + MassStr + PowerStr + BrakeStr + MaxSpeedStr;
15405 for(
unsigned int z = 0; z < ActionVector.size(); z++)
15410 AnsiString PartStr =
"", TimeStr =
"";
15427 PartStr =
"Enters at " + ActionVectorEntry.
LocationName;
15431 PartStr =
"Created at " + ActionVectorEntry.
LocationName;
15441 PartStr =
"Enters at " + LocName;
15454 PartStr =
"Created at " + LocName;
15468 PartStr =
"Enters at " + ActionVectorEntry.
LocationName;
15473 PartStr =
"Repeat shuttle service at " + ActionVectorEntry.
LocationName +
" from ";
15479 else if(ActionVectorEntry.
Command ==
"Sfs")
15481 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" split from";
15485 else if(ActionVectorEntry.
Command ==
"Sns")
15487 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" from";
15495 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" from";
15501 PartStr =
"Repeat shuttle service at " + ActionVectorEntry.
LocationName +
" from ";
15509 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" from";
15512 AnsiString FirstHeadCode = TDE->
HeadCode;
15516 TimeStr =
GetRepeatHeadCode(36, FirstHeadCode, LastRepeatNumber, IncrementalDigits) +
" at " +
15528 PartStr =
"Arrives at " + ActionVectorEntry.
LocationName;
15530 OneTTEntry.
Action = PartStr;
15531 OneTTEntry.
Time = TimeStr;
15533 PartStr =
"Departs from " + ActionVectorEntry.
LocationName;
15538 PartStr =
"Arrives & departs " + ActionVectorEntry.
LocationName;
15544 PartStr =
"Arrives at " + ActionVectorEntry.
LocationName;
15549 PartStr =
"Departs from " + ActionVectorEntry.
LocationName;
15557 else if(ActionVectorEntry.
Command ==
"jbo")
15559 PartStr =
"Joined at " + ActionVectorEntry.
LocationName +
" by";
15563 else if(ActionVectorEntry.
Command ==
"fsp")
15565 PartStr =
"Splits from front at " + ActionVectorEntry.
LocationName +
" to form";
15569 else if(ActionVectorEntry.
Command ==
"rsp")
15571 PartStr =
"Splits from rear at " + ActionVectorEntry.
LocationName +
" to form";
15575 else if(ActionVectorEntry.
Command ==
"cdt")
15577 PartStr =
"Changes direction at " + ActionVectorEntry.
LocationName;
15583 if(ActionVectorEntry.
Command ==
"Fns")
15585 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15589 else if(ActionVectorEntry.
Command ==
"F-nshs")
15591 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15597 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service ";
15604 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15610 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15617 PartStr =
"Terminates shuttle service at " + ActionVectorEntry.
LocationName;
15622 else if(ActionVectorEntry.
Command ==
"Frh")
15624 PartStr =
"Terminates at " + ActionVectorEntry.
LocationName;
15629 if(ActionVector.at(z - 1).EventTime != TDateTime(-1))
15633 else if(ActionVector.at(z - 1).ArrivalTime != TDateTime(-1))
15643 else if(ActionVectorEntry.
Command ==
"Fer")
15645 AnsiString AllowedExits;
15649 else if(ActionVectorEntry.
Command ==
"Fjo")
15651 PartStr =
"At " + ActionVectorEntry.
LocationName +
" joins";
15660 OneTTEntry.
Action = PartStr;
15661 OneTTEntry.
Time = TimeStr;
15668 AllTTTrains->push_back(OneTTLine);
15672 std::ofstream TTFile(TTFileName.c_str());
15676 StopTTClockMessage(64,
"Formatted timetable file failed to open - can't be created");
15677 delete AllTTTrains;
15712 TTFile << TableTitle.c_str() <<
'\n' <<
'\n';
15713 for(
unsigned int x = 0; x < AllTTTrains->size(); x++)
15715 TTFile << AllTTTrains->at(x).Header.c_str();
15718 for(
int y = 0; y < AllTTTrains->at(x).NumberOfTrains; y++)
15720 if(y < (AllTTTrains->at(x).NumberOfTrains - 1))
15722 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).HeadCode.c_str() <<
',';
15726 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).HeadCode.c_str();
15729 TTFile <<
'\n' <<
'\n';
15731 for(
unsigned int z = 0; z < AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(0).OneFormattedTrainVector.size(); z++)
15733 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(0).OneFormattedTrainVector.at(z).Action.c_str() <<
',';
15734 for(
int y = 0; y < AllTTTrains->at(x).NumberOfTrains; y++)
15736 if(y < (AllTTTrains->at(x).NumberOfTrains - 1))
15738 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Time.c_str() <<
',';
15742 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Time.c_str();
15747 TTFile <<
'\n' <<
'\n';
15752 AnsiString TTFileName2 = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
15754 TTFileName2 = CurDir +
"\\Formatted timetables\\Timetable " + TTFileName2 +
"; " + RailwayTitle +
"; " + TimetableTitle +
".txt";
15756 std::ofstream TTFile2(TTFileName2.c_str());
15760 StopTTClockMessage(67,
"Chronological timetable file failed to open - can't be created");
15761 delete AllTTTrains;
15765 typedef std::multimap<AnsiString, AnsiString>TAnsiMultiMap;
15766 std::multimap<AnsiString, AnsiString>::iterator AMMIT;
15767 std::pair<AnsiString, AnsiString>AnsiMultiMapEntry;
15769 TAnsiMultiMap *TAMM =
new TAnsiMultiMap;
15774 TTFile2 << TableTitle.c_str() <<
'\n' <<
'\n';
15775 for(
unsigned int x = 0; x < AllTTTrains->size(); x++)
15777 for(
int y = 0; y < AllTTTrains->at(x).NumberOfTrains; y++)
15779 for(
unsigned int z = 0; z < AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.size(); z++)
15781 bool GiveMessagesFalse =
false;
15782 AnsiString TimeString = AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Time;
15783 AnsiString HeadCodeString = AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).HeadCode;
15784 AnsiString ActionString = AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Action;
15789 AnsiString OtherHeadCode = TimeString.SubString(1, 4);
15790 TimeString = TimeString.SubString(9, 5);
15791 ActionString +=
" " + OtherHeadCode;
15793 if(TimeString.SubString(1, 7) ==
"End at ")
15796 TimeString = TimeString.SubString(8, 5);
15798 AnsiString OneLine = TimeString +
' ' + HeadCodeString +
' ' + ActionString +
'\n';
15799 AnsiMultiMapEntry.first = TimeString;
15800 AnsiMultiMapEntry.second = OneLine;
15801 TAMM->insert(AnsiMultiMapEntry);
15806 for(AMMIT = TAMM->begin(); AMMIT != TAMM->end(); AMMIT++)
15808 TTFile2 << (AMMIT->second).c_str();
15810 delete AllTTTrains;
15819 bool AtLocChecked,
int ArrRange,
int DepRange)
15823 bool AnalysisError =
false;
15847 TTrainDataVector::iterator TDVIt, TDVCopyIt;
15849 int IteratorNumber = 0;
15850 AnsiString AnsiSuffix =
"";
15855 for(TDVCopyIt = TrainDataVectorCopy.begin() + IteratorNumber; TDVCopyIt != TrainDataVectorCopy.end(); TDVCopyIt++)
15857 if(TDVCopyIt->ServiceReference == TDVIt->ServiceReference)
15860 AnsiSuffix = AnsiString(Suffix);
15861 TDVCopyIt->ServiceReference = TDVIt->ServiceReference +
"/" + AnsiSuffix;
15868 std::pair<AnsiString, TServiceCallingLocsList> AllServiceCallingLocsEntry;
15869 for(
unsigned int x = 0; x < TrainDataVectorCopy.size(); x++)
15874 ServiceCallingLocsList.clear();
15875 if(ActionVector.empty())
15879 if(ActionVector.at(0).SignallerControl)
15883 for(
unsigned int z = 0; z < ActionVector.size(); z++)
15901 int HLoc = TE.
HLoc;
15902 int VLoc = TE.
VLoc;
15903 AnsiString HString;
15904 AnsiString VString;
15907 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
15911 HString = AnsiString(HLoc);
15915 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
15919 VString = AnsiString(VLoc);
15921 ServiceCallingLocsList.push_back(HString +
'-' + VString);
15944 else if(AVE.
Command ==
"cdt")
15946 if(ActionVector.at(z-1).SequenceType ==
Start)
15950 else if(ActionVector.at(z+1).SequenceType ==
Finish)
15957 ServiceCallingLocsList.push_back(
"%%%" + TimeString);
15966 ServiceCallingLocsList.push_back(LName);
15970 int HLoc = TE.
HLoc;
15971 int VLoc = TE.
VLoc;
15972 AnsiString HString;
15973 AnsiString VString;
15976 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
15980 HString = AnsiString(HLoc);
15984 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
15988 VString = AnsiString(VLoc);
15990 ServiceCallingLocsList.push_back(HString +
'-' + VString);
15994 AllServiceCallingLocsEntry.second = ServiceCallingLocsList;
16028 ShowMessage(
"Unable to create a program-readable timetable - please check the timetable file validity");
16034 bool NumPlatsAtThisLocCalculated =
false, ArrivalsPrinted =
false, DeparturesPrinted =
false, AtLocsPrinted =
false;
16035 AnsiString PreviousService =
"", PreviousServiceAndRepeatNumTotalOutput =
"", BasicTime =
"", MinuteString =
"", LastAnsiTime =
"";
16036 int NumTrains = 0, NumPlats = 0, LastFrhCount = 0, FrhCount = 0, NumTrainsAtLoc = 0;
16040 for(
unsigned int x = 0; x < TrainDataVectorCopy.size(); x++)
16045 TDateTime LastTDTime;
16046 int IncMinutes = 0;
16048 if(ActionVector.empty())
16052 if(ActionVector.at(0).SignallerControl)
16056 if(AVLast->FormatType ==
Repeat)
16058 IncMinutes = ActionVector.at(ActionVector.size() - 1).RearStartOrRepeatMins;
16066 if(AVLast->ArrivalTime != TDateTime(-1))
16068 LastTDTime = AVLast->ArrivalTime;
16070 else if(AVLast->EventTime != TDateTime(-1))
16072 LastTDTime = AVLast->EventTime;
16121 for(
unsigned int x = 0; x < TrainDataVectorCopy.size(); x++)
16126 int IncMinutes = 0;
16128 if(ActionVector.empty())
16132 if(ActionVector.at(0).SignallerControl)
16136 if(ActionVector.at(ActionVector.size() - 1).FormatType ==
Repeat)
16138 IncMinutes = ActionVector.at(ActionVector.size() - 1).RearStartOrRepeatMins;
16140 for(
int y = 0; y < NumTrains; y++)
16154 for(
unsigned int z = 0; z < ActionVector.size(); z++)
16169 LocServiceTimesVector.push_back(TLSTEntry);
16172 AnsiString IncTime =
"", FoundStopTime =
"";
16173 for(
unsigned int a = z + 1; a < ActionVector.size(); a++)
16175 if(ActionVector.at(a).FormatType ==
TimeLoc)
16180 if(ActionVector.at(a).SequenceType ==
Finish)
16186 if(FoundStopTime ==
"")
16188 throw Exception(
"Failure to determine FoundStopTime for located Snt");
16190 int WhileCount = 0;
16199 if(IncTime >= FoundStopTime)
16203 LocServiceTimesVector.push_back(TLSTEntry);
16204 if(WhileCount > 2000)
16206 throw Exception(
"While loop failed to break in 2000 loops for located Snt");
16219 int HLoc = TE.
HLoc;
16220 int VLoc = TE.
VLoc;
16221 AnsiString HString;
16222 AnsiString VString;
16225 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
16229 HString = AnsiString(HLoc);
16233 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
16237 VString = AnsiString(VLoc);
16239 TLSTEntry.
Location = HString +
'-' + VString;
16243 LocServiceTimesVector.push_back(TLSTEntry);
16251 LocServiceTimesVector.push_back(TLSTEntry);
16253 AnsiString IncTime =
"", FoundStopTime =
"";
16254 for(
unsigned int a = z + 1; a < ActionVector.size(); a++)
16256 if(ActionVector.at(a).FormatType ==
TimeLoc)
16261 if(ActionVector.at(a).SequenceType ==
Finish)
16267 if(FoundStopTime ==
"")
16269 throw Exception(
"Failure to determine FoundStopTime for SequenceType == Start");
16271 int WhileCount = 0;
16280 if(IncTime >= FoundStopTime)
16284 LocServiceTimesVector.push_back(TLSTEntry);
16285 if(WhileCount > 2000)
16287 throw Exception(
"While loop failed to break in 2000 loops for SequenceType == Start");
16297 bool SkipAddingMinutes =
false;
16300 LocServiceTimesVector.push_back(TLSTEntry);
16302 AnsiString IncTime =
"", FoundStopTime =
"";
16303 for(
unsigned int a = z + 1; a < ActionVector.size(); a++)
16305 if(ActionVector.at(a).FormatType ==
TimeLoc)
16310 if(ActionVector.at(a).SequenceType ==
Finish)
16313 if((a == z + 1) && (FoundStopTime == TLSTEntry.
ArrTime) && ((ActionVector.at(a).LinkedTrainEntryPtr > 0) || (ActionVector.at(a).NonRepeatingShuttleLinkEntryPtr > 0)))
16316 LocServiceTimesVector.pop_back();
16317 SkipAddingMinutes =
true;
16322 if(FoundStopTime ==
"")
16324 throw Exception(
"Failure to determine FoundStopTime for SequenceType == Start");
16326 if(!SkipAddingMinutes)
16328 int WhileCount = 0;
16337 if(IncTime >= FoundStopTime)
16341 LocServiceTimesVector.push_back(TLSTEntry);
16342 if(WhileCount > 2000)
16344 throw Exception(
"While loop failed to break in 2000 loops for SequenceType == Start");
16353 if((TLSTEntry.
Location == LocServiceTimesVector.back().Location) && (TLSTEntry.
ServiceAndRepeatNum == LocServiceTimesVector.back().ServiceAndRepeatNum))
16355 if(TLSTEntry.
DepTime == LocServiceTimesVector.back().ArrTime)
16357 TLSTEntry.
ArrTime = LocServiceTimesVector.back().ArrTime;
16358 LocServiceTimesVector.pop_back();
16359 LocServiceTimesVector.push_back(TLSTEntry);
16364 LocServiceTimesVector.push_back(TLSTEntry);
16370 LocServiceTimesVector.push_back(TLSTEntry);
16389 LocServiceTimesVector.push_back(TLSTEntry);
16393 AnsiString TempDepTime = TLSTEntry.
DepTime;
16395 LocServiceTimesVector.push_back(TLSTEntry);
16397 while(TLSTEntry.
AtLocTime < TempDepTime)
16402 TLSTEntry.
DepTime = TempDepTime;
16403 LocServiceTimesVector.push_back(TLSTEntry);
16407 LocServiceTimesVector.push_back(TLSTEntry);
16425 AnsiString HString;
16426 AnsiString VString;
16429 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
16433 HString = AnsiString(HLoc);
16437 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
16441 VString = AnsiString(VLoc);
16443 TLSTEntry.
Location = HString +
'-' + VString;
16445 LocServiceTimesVector.push_back(TLSTEntry);
16450 AnsiString FrhTime;
16451 if(ActionVector.at(z - 1).ArrivalTime != TDateTime(-1))
16455 else if(ActionVector.at(z - 1).EventTime != TDateTime(-1))
16463 LocServiceTimesVector.push_back(TLSTEntry);
16469 LocServiceTimesVector.push_back(TLSTEntry);
16474 else if(AVE.
Command ==
"Frh-sh")
16476 if(y == NumTrains - 1)
16482 LocServiceTimesVector.push_back(TLSTEntry);
16488 LocServiceTimesVector.push_back(TLSTEntry);
16507 TLocServiceTimesVector::iterator Ptr1, Ptr2;
16510 AnsiString TTFileName3 = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
16511 TTFileName3 = CurDir +
"\\Formatted timetables\\Conflict Analysis " + TTFileName3 +
"; " + RailwayTitle +
"; " + TimetableTitle +
".csv";
16513 std::ofstream TTFile3(TTFileName3.c_str());
16517 ShowMessage(
"Conflict Analysis file failed to open - can't be created");
16521 if(LocServiceTimesVector.empty())
16523 ShowMessage(
"No timetabled services found");
16525 DeleteFile(TTFileName3);
16529 TTFile3 <<
"Timetable analysis for timetable: '" + TimetableTitle +
"' in conjunction with railway: '" + RailwayTitle +
"'\n\n\n";
16536 Ptr1 = LocServiceTimesVector.begin();
16538 while(Ptr2 != LocServiceTimesVector.end())
16540 while(Ptr2->Location == Ptr1->Location)
16543 if(Ptr2 == LocServiceTimesVector.end())
16550 if(Ptr2 != LocServiceTimesVector.end())
16558 TTFile3 <<
"Arrival analysis: an asterisk means that the number of same approach code arrivals is equal to or greater than the number of platforms.\n";
16559 TTFile3 <<
"If the total number of arrivals exceeds the number of platforms the 'Trains present at location analysis' will show an asterisk.\n\n";
16560 MinuteString =
" minutes";
16561 AnsiString ServiceAndRepeatNumTotal =
"", ServiceAndRepeatNumTotalOutput =
"";
16564 MinuteString =
" minute";
16566 TTFile3 <<
"Location,Number of,Number of,Services arriving within " << AnsiString(ArrRange) << MinuteString <<
" with their arrival times and approach codes\n";
16567 TTFile3 <<
",Platforms,Trains\n\n";
16569 Ptr1 = LocServiceTimesVector.begin();
16571 while(Ptr2 != LocServiceTimesVector.end())
16573 PreviousService =
"";
16574 NumTrainsAtLoc = 0;
16575 ServiceAndRepeatNumTotal =
"";
16577 NumPlatsAtThisLocCalculated =
false;
16579 while((Ptr2->Location != Ptr1->Location) || ((Ptr1->Location ==
"") && (Ptr2->Location ==
"")))
16581 PreviousService =
"";
16582 NumTrainsAtLoc = 0;
16583 ServiceAndRepeatNumTotal =
"";
16585 NumPlatsAtThisLocCalculated =
false;
16589 if(Ptr2 == LocServiceTimesVector.end())
16594 if(Ptr2 == LocServiceTimesVector.end())
16598 while(Ptr2->Location == Ptr1->Location)
16600 PreviousService =
"";
16601 NumTrainsAtLoc = 0;
16602 ServiceAndRepeatNumTotal =
"";
16603 BasicTime = Ptr1->ArrTime;
16604 if((Ptr1->Location ==
"") && (Ptr2->Location ==
""))
16608 while(!
WithinTimeRange(0, BasicTime, Ptr2->ArrTime, ArrRange) || ((Ptr1->ArrTime ==
"") && (Ptr2->ArrTime ==
"")))
16610 BasicTime = Ptr2->ArrTime;
16613 if(Ptr2 == LocServiceTimesVector.end())
16617 if(Ptr2->Location != Ptr1->Location)
16622 if(Ptr2 == LocServiceTimesVector.end())
16626 if(Ptr2->Location != Ptr1->Location)
16632 if((Ptr1->ArrTime ==
"") && (Ptr2->ArrTime ==
""))
16636 if(!NumPlatsAtThisLocCalculated)
16639 NumPlatsAtThisLocCalculated =
true;
16641 if(Ptr1->ServiceAndRepeatNum != PreviousService)
16643 if(ServiceAndRepeatNumTotal ==
"")
16645 ServiceAndRepeatNumTotal = Ptr1->ServiceAndRepeatNum +
"," + Ptr1->ArrTime;
16646 NumTrainsAtLoc = 1;
16650 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr1->ServiceAndRepeatNum +
"," + Ptr1->ArrTime;
16653 PreviousService = Ptr2->ServiceAndRepeatNum;
16654 if(ServiceAndRepeatNumTotal ==
"")
16656 ServiceAndRepeatNumTotal = Ptr2->ServiceAndRepeatNum +
"," + Ptr2->ArrTime;
16657 NumTrainsAtLoc = 1;
16661 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr2->ServiceAndRepeatNum +
"," + Ptr2->ArrTime;
16665 if((Ptr2 == LocServiceTimesVector.end()) || (Ptr2->Location != Ptr1->Location) || (!
WithinTimeRange(2, BasicTime, Ptr2->ArrTime, ArrRange)))
16667 int MaxNumberOfSameDirections = 0;
16668 ServiceAndRepeatNumTotalOutput =
ConsolidateSARNTArrDep(1, ServiceAndRepeatNumTotal, NumTrainsAtLoc, Ptr1->Location,
true, AnalysisError, MaxNumberOfSameDirections);
16673 throw Exception(ServiceAndRepeatNumTotalOutput.c_str());
16677 AnsiString Asterisk =
"";
16678 if(MaxNumberOfSameDirections >= NumPlats)
16683 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << ServiceAndRepeatNumTotalOutput <<
'\n';
16684 ArrivalsPrinted =
true;
16685 ServiceAndRepeatNumTotal =
"";
16687 if(Ptr2 == LocServiceTimesVector.end())
16691 if(Ptr2->Location != Ptr1->Location)
16696 if(Ptr2 == LocServiceTimesVector.end())
16702 if(!ArrivalsPrinted)
16704 TTFile3 <<
"Nothing to report for arrivals";
16706 TTFile3 <<
"\n\n\n";
16714 Ptr1 = LocServiceTimesVector.begin();
16716 while(Ptr2 != LocServiceTimesVector.end())
16718 while(Ptr2->Location == Ptr1->Location)
16721 if(Ptr2 == LocServiceTimesVector.end())
16728 if(Ptr2 != LocServiceTimesVector.end())
16735 TTFile3 <<
"Departure analysis: an asterisk means that the number of same exit code departures is equal to or greater than the number of platforms.\n";
16736 TTFile3 <<
"If the total number of departures exceeds the number of platforms the 'Trains present at location analysis' will show an asterisk.\n\n";
16737 MinuteString =
" minutes";
16738 AnsiString ServiceAndRepeatNumTotal =
"", ServiceAndRepeatNumTotalOutput =
"";
16741 MinuteString =
" minute";
16743 TTFile3 <<
"Location,Number of,Number of,Services departing within " << AnsiString(DepRange) << MinuteString <<
" with their departure times and exit codes\n";
16744 TTFile3 <<
",Platforms,Trains\n\n";
16746 Ptr1 = LocServiceTimesVector.begin();
16748 while(Ptr2 != LocServiceTimesVector.end())
16750 PreviousService =
"";
16751 NumTrainsAtLoc = 0;
16752 ServiceAndRepeatNumTotal =
"";
16754 NumPlatsAtThisLocCalculated =
false;
16756 while((Ptr2->Location != Ptr1->Location) || ((Ptr1->Location ==
"") && (Ptr2->Location ==
"")))
16758 PreviousService =
"";
16759 NumTrainsAtLoc = 0;
16760 ServiceAndRepeatNumTotal =
"";
16762 NumPlatsAtThisLocCalculated =
false;
16766 if(Ptr2 == LocServiceTimesVector.end())
16771 if(Ptr2 == LocServiceTimesVector.end())
16775 while(Ptr2->Location == Ptr1->Location)
16777 PreviousService =
"";
16778 NumTrainsAtLoc = 0;
16779 ServiceAndRepeatNumTotal =
"";
16780 BasicTime = Ptr1->DepTime;
16781 if((Ptr1->Location ==
"") && (Ptr2->Location ==
""))
16785 while(!
WithinTimeRange(3, BasicTime, Ptr2->DepTime, DepRange) || ((Ptr1->DepTime ==
"") && (Ptr2->DepTime ==
"")))
16787 BasicTime = Ptr2->DepTime;
16790 if(Ptr2 == LocServiceTimesVector.end())
16794 if(Ptr2->Location != Ptr1->Location)
16799 if(Ptr2 == LocServiceTimesVector.end())
16803 if(Ptr2->Location != Ptr1->Location)
16809 if((Ptr1->DepTime ==
"") && (Ptr2->DepTime ==
""))
16813 if(!NumPlatsAtThisLocCalculated)
16816 NumPlatsAtThisLocCalculated =
true;
16818 if(Ptr1->ServiceAndRepeatNum != PreviousService)
16820 if(ServiceAndRepeatNumTotal ==
"")
16822 ServiceAndRepeatNumTotal = Ptr1->ServiceAndRepeatNum +
"," + Ptr1->DepTime;
16823 NumTrainsAtLoc = 1;
16827 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr1->ServiceAndRepeatNum +
"," + Ptr1->DepTime;
16830 PreviousService = Ptr2->ServiceAndRepeatNum;
16831 if(ServiceAndRepeatNumTotal ==
"")
16833 ServiceAndRepeatNumTotal = Ptr2->ServiceAndRepeatNum +
"," + Ptr2->DepTime;
16834 NumTrainsAtLoc = 1;
16838 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr2->ServiceAndRepeatNum +
"," + Ptr2->DepTime;
16842 if((Ptr2 == LocServiceTimesVector.end()) || (Ptr2->Location != Ptr1->Location) || (!
WithinTimeRange(5, BasicTime, Ptr2->DepTime, DepRange)))
16844 int MaxNumberOfSameDirections = 0;
16845 ServiceAndRepeatNumTotalOutput =
ConsolidateSARNTArrDep(3, ServiceAndRepeatNumTotal, NumTrainsAtLoc, Ptr1->Location,
false, AnalysisError, MaxNumberOfSameDirections);
16850 throw Exception(ServiceAndRepeatNumTotalOutput.c_str());
16854 AnsiString Asterisk =
"";
16855 if(MaxNumberOfSameDirections >= NumPlats)
16860 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << ServiceAndRepeatNumTotalOutput <<
'\n';
16861 DeparturesPrinted =
true;
16862 ServiceAndRepeatNumTotal =
"";
16864 if(Ptr2 == LocServiceTimesVector.end())
16868 if(Ptr2->Location != Ptr1->Location)
16873 if(Ptr2 == LocServiceTimesVector.end())
16879 if(!DeparturesPrinted)
16881 TTFile3 <<
"Nothing to report for departures";
16883 TTFile3 <<
"\n\n\n";
16893 Ptr1 = LocServiceTimesVector.begin();
16895 while(Ptr2 != LocServiceTimesVector.end())
16897 while(Ptr2->Location == Ptr1->Location)
16900 if(Ptr2 == LocServiceTimesVector.end())
16907 if(Ptr2 != LocServiceTimesVector.end())
16914 TTFile3 <<
"Trains present at location analysis: an asterisk means that the number of trains at the location is greater than the number of platforms.\n\n";
16915 TTFile3 <<
"Location,Number of,Number of,Time,Services at the location at that time\n";
16916 TTFile3 <<
",Platforms,Trains,\n\n";
16917 AnsiString ServiceAndRepeatNumTotal =
"", ServiceAndRepeatNumTotalOutput =
"";
16918 Ptr1 = LocServiceTimesVector.begin();
16920 while(Ptr2 != LocServiceTimesVector.end())
16922 PreviousService =
"";
16923 ServiceAndRepeatNumTotal =
"";
16924 NumTrainsAtLoc = 0;
16926 NumPlatsAtThisLocCalculated =
false;
16928 while((Ptr2->Location != Ptr1->Location) || ((Ptr1->Location ==
"") && (Ptr2->Location ==
"")))
16930 PreviousService =
"";
16931 ServiceAndRepeatNumTotal =
"";
16932 NumTrainsAtLoc = 0;
16934 NumPlatsAtThisLocCalculated =
false;
16938 if(Ptr2 == LocServiceTimesVector.end())
16943 if(Ptr2 == LocServiceTimesVector.end())
16947 while(Ptr2->Location == Ptr1->Location)
16949 if(Ptr1->FrhMarker ==
"Frh")
16952 Ptr1->FrhMarker =
"FrhCounted";
16954 PreviousService =
"";
16955 NumTrainsAtLoc = 0;
16956 ServiceAndRepeatNumTotal =
"";
16957 if((Ptr1->Location ==
"") && (Ptr2->Location ==
""))
16961 while((Ptr2->AtLocTime != Ptr1->AtLocTime) || ((Ptr1->AtLocTime ==
"") && (Ptr2->AtLocTime ==
"")))
16964 if(Ptr1->FrhMarker ==
"Frh")
16967 Ptr1->FrhMarker =
"FrhCounted";
16970 if(Ptr2 == LocServiceTimesVector.end())
16974 if(Ptr2->Location != Ptr1->Location)
16979 if(Ptr2 == LocServiceTimesVector.end())
16983 if(Ptr2->Location != Ptr1->Location)
16987 while(Ptr2->AtLocTime == Ptr1->AtLocTime)
16989 if((Ptr1->AtLocTime ==
"") && (Ptr2->AtLocTime ==
""))
16993 if(!NumPlatsAtThisLocCalculated)
16996 NumPlatsAtThisLocCalculated =
true;
16998 if(Ptr1->ServiceAndRepeatNum != PreviousService)
17000 if(ServiceAndRepeatNumTotal ==
"")
17002 ServiceAndRepeatNumTotal = Ptr1->ServiceAndRepeatNum;
17003 NumTrainsAtLoc = 1;
17007 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr1->ServiceAndRepeatNum;
17010 PreviousService = Ptr2->ServiceAndRepeatNum;
17011 if(ServiceAndRepeatNumTotal ==
"")
17013 ServiceAndRepeatNumTotal = Ptr2->ServiceAndRepeatNum;
17014 NumTrainsAtLoc = 1;
17018 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr2->ServiceAndRepeatNum;
17021 if(Ptr1->FrhMarker ==
"Frh")
17024 Ptr1->FrhMarker =
"FrhCounted";
17027 if((Ptr2 == LocServiceTimesVector.end()) || (Ptr2->Location != Ptr1->Location) || (Ptr2->AtLocTime != Ptr1->AtLocTime))
17031 ServiceAndRepeatNumTotalOutput =
ConsolidateSARNTAtLoc(1, ServiceAndRepeatNumTotal, NumTrainsAtLoc);
17033 if((NumTrainsAtLoc > 1) && ((FrhCount < NumTrainsAtLoc) || (FrhCount != LastFrhCount)))
17035 AnsiString Asterisk =
"";
17036 if(NumTrainsAtLoc > NumPlats)
17043 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << Ptr1->AtLocTime <<
"," << ServiceAndRepeatNumTotalOutput <<
'\n';
17045 else if(FrhCount == 1)
17047 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << Ptr1->AtLocTime <<
" (1 remains here)," << ServiceAndRepeatNumTotalOutput <<
'\n';
17051 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << Ptr1->AtLocTime <<
" (" << FrhCount <<
" remain here)," << ServiceAndRepeatNumTotalOutput <<
'\n';
17053 LastFrhCount = FrhCount;
17054 PreviousServiceAndRepeatNumTotalOutput = ServiceAndRepeatNumTotalOutput;
17055 AtLocsPrinted =
true;
17056 ServiceAndRepeatNumTotal =
"";
17059 if(Ptr2 == LocServiceTimesVector.end())
17063 if(Ptr2->Location != Ptr1->Location)
17068 if(Ptr2 == LocServiceTimesVector.end())
17076 TTFile3 <<
"Nothing to report for trains at locations";
17078 TTFile3 <<
"\n\n\n";
17099 catch(
const Exception &e)
17101 AnsiString TTErrorFileName =
"Analysis Error.txt";
17102 TTErrorFileName = CurDir +
"\\Formatted timetables\\" + TTErrorFileName;
17103 std::ofstream TTError(TTErrorFileName.c_str());
17106 ShowMessage(
"Analysis error file failed to open - can't be created");
17110 AnsiString TimeNow = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
17111 TTError << TimeNow.c_str() <<
"\n" << ArrRange <<
"\n" << ArrChecked <<
"\n" << DepRange <<
"\n" <<
17112 DepChecked <<
"\n" << AtLocChecked <<
"\n" << AnsiString(e.Message);
17114 ShowMessage(
"Error in Conflict Analysis: A file called 'Analysis Error.txt' has been created in your Formatted timetables folder. Please send this file together with your railway and timetable files to railwayfeedback@gmail.com for investigation - many thanks");
17126 if((Time1 ==
"") || (Time2 ==
""))
17131 int Mins = Time1.SubString(4,2).ToInt();
17132 int Hours = Time1.SubString(1,2).ToInt();
17133 int Time1Mins = (Hours * 60) + Mins;
17134 Mins = Time2.SubString(4,2).ToInt();
17135 Hours = Time2.SubString(1,2).ToInt();
17136 int Time2Mins = (Hours * 60) + Mins;
17137 if(abs(Time1Mins - Time2Mins) <= MinuteRange)
17149 bool &AnalysisError,
int &MaxNumberOfSameDirections)
17156 AnsiString Output =
"", OneService =
"", TempStr1 =
"", TempStr2 =
"";
17158 std::list<AnsiString> ServiceList;
17160 bool EvenComma =
false;
17161 for(
int x = 1; x <= Input.Length(); x++)
17163 TempStr1 = Input[x];
17164 if(TempStr1 == AnsiString(
',') && EvenComma)
17170 TempStr2 += Input[x];
17172 if(TempStr1 == AnsiString(
','))
17174 EvenComma = !EvenComma;
17178 while(TempStr2.Length() > 0)
17180 SCPos = TempStr2.Pos(
';');
17183 OneService = TempStr2.SubString(1, SCPos - 1);
17184 ServiceList.push_back(OneService);
17185 TempStr2 = TempStr2.SubString(SCPos + 1, TempStr2.Length() - SCPos);
17189 ServiceList.push_back(TempStr2);
17193 ServiceList.sort();
17194 ServiceList.unique();
17195 NumTrainsAtLoc = ServiceList.size();
17198 int DirectionMarker = 0;
17200 std::list<AnsiString>::iterator SLIt, SLIt1, SLIt2, SLIt3;
17202 for(SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17204 *SLIt = *SLIt +
"&0";
17206 SLIt3 = ServiceList.end();
17208 AnsiString ServiceRef1, ServiceRef2, AnsiTime1, AnsiTime2, RepeatInfo1, RepeatInfo2;
17209 int AmpersandPos, SpacePos, CommaPos1, CommaPos2, RepeatNum1, RepeatNum2;
17210 TAllServiceCallingLocsMap::iterator ASCLIt1, ASCLIt2;
17212 MaxNumberOfSameDirections = 0;
17213 int SameDirectionCount = 0;
17215 for(std::list<AnsiString>::iterator SLIt1 = ServiceList.begin(); SLIt1 != SLIt3; SLIt1++)
17219 if(SLIt1->SubString(SLIt1->Length() - 1, 2) != AnsiString(
"&0"))
17225 CommaPos1 = SLIt1->Pos(
',');
17226 ServiceRef1 = SLIt1->SubString(1, CommaPos1 - 1);
17228 SpacePos = ServiceRef1.Pos(
' ');
17232 RepeatInfo1 = ServiceRef1.SubString(SpacePos + 2, ServiceRef1.Length() - SpacePos - 2);
17233 ServiceRef1 = ServiceRef1.SubString(1, SpacePos - 1);
17234 if(RepeatInfo1[1] ==
'F')
17240 SpacePos = RepeatInfo1.Pos(
' ');
17241 RepeatNum1 = RepeatInfo1.SubString(SpacePos + 1, RepeatInfo1.Length() - SpacePos).ToInt();
17244 AnsiTime1 = SLIt1->SubString(CommaPos1 + 1, SLIt1->Length() - CommaPos1);
17246 AmpersandPos = AnsiTime1.Pos(
'&');
17247 AnsiTime1 = AnsiTime1.SubString(1, AmpersandPos - 1);
17252 throw Exception(
"ASCLIt1 Error in " + Input);
17254 ServiceCallingLocsList1 = ASCLIt1->second;
17255 AmpersandPos = SLIt1->Pos(
'&');
17256 *SLIt1 = SLIt1->SubString(1, AmpersandPos);
17257 *SLIt1 = *SLIt1 + AnsiString(++DirectionMarker);
17259 SameDirectionCount = 1;
17260 for(SLIt2 = SLIt; SLIt2 != ServiceList.end(); SLIt2++)
17262 CommaPos2 = SLIt2->Pos(
',');
17263 ServiceRef2 = SLIt2->SubString(1, CommaPos2 - 1);
17265 SpacePos = ServiceRef2.Pos(
' ');
17269 RepeatInfo2 = ServiceRef2.SubString(SpacePos + 2, ServiceRef2.Length() - SpacePos - 2);
17270 ServiceRef2 = ServiceRef2.SubString(1, SpacePos - 1);
17271 if(RepeatInfo2[1] ==
'F')
17277 SpacePos = RepeatInfo2.Pos(
' ');
17278 RepeatNum2 = RepeatInfo2.SubString(SpacePos + 1, RepeatInfo2.Length() - SpacePos).ToInt();
17281 AnsiTime2 = SLIt2->SubString(CommaPos2 + 1, SLIt2->Length() - CommaPos2);
17283 AmpersandPos = AnsiTime2.Pos(
'&');
17284 AnsiTime2 = AnsiTime2.SubString(1, AmpersandPos - 1);
17289 throw Exception(
"ASCLIt2 Error in " + Input);
17291 ServiceCallingLocsList2 = ASCLIt2->second;
17293 if(
SameDirection(0, ServiceRef1, ServiceRef2, AnsiTime1, AnsiTime2, RepeatNum1, RepeatNum2, ServiceCallingLocsList1, ServiceCallingLocsList2, Location, Arrival))
17295 int AmpersandPos = SLIt2->Pos(
'&');
17296 *SLIt2 = SLIt2->SubString(1, AmpersandPos);
17297 *SLIt2 = *SLIt2 + AnsiString(DirectionMarker);
17298 SameDirectionCount++;
17301 if(SameDirectionCount > MaxNumberOfSameDirections)
17303 MaxNumberOfSameDirections = SameDirectionCount;
17308 if(SLIt3->SubString(SLIt3->Length() - 1, 2) == AnsiString(
"&0"))
17311 AmpersandPos = SLIt3->Pos(
'&');
17312 *SLIt3 = SLIt3->SubString(1, AmpersandPos);
17313 *SLIt3 = *SLIt3 + AnsiString(++DirectionMarker);
17316 for(SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17319 AmpersandPos = SLIt->Pos(
'&');
17320 AnsiString DirectionMarkerString = SLIt->SubString(AmpersandPos + 1, SLIt->Length() - AmpersandPos);
17321 AnsiString ServiceWithoutMarker = SLIt->SubString(1, AmpersandPos - 1);
17322 DirectionMarker = DirectionMarkerString.ToInt();
17323 AnsiString DirectionSuffix =
"";
17325 if(DirectionMarker < 27)
17327 c = 64 + DirectionMarker;
17328 DirectionSuffix =
"," + AnsiString(c);
17330 else if(DirectionMarker < 53)
17332 c = 65 + DirectionMarker - 27;
17333 DirectionSuffix =
",A" + AnsiString(c);
17337 DirectionSuffix =
",?";
17339 *SLIt = ServiceWithoutMarker + DirectionSuffix;
17342 for(SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17344 Output = Output + *SLIt +
",";
17346 if(Output.Length() > 0)
17348 Output = Output.SubString(1, Output.Length() - 1);
17354 catch(
const Exception &e)
17356 AnalysisError =
true;
17368 AnsiString InternalInput = Input, Output =
"", OneService =
"";
17370 std::list<AnsiString> ServiceList;
17372 while(InternalInput.Length() > 0)
17374 CommaPos = InternalInput.Pos(
',');
17377 OneService = InternalInput.SubString(1, CommaPos - 1);
17378 ServiceList.push_back(OneService);
17379 InternalInput = InternalInput.SubString(CommaPos + 1, InternalInput.Length() - CommaPos);
17383 ServiceList.push_back(InternalInput);
17384 InternalInput =
"";
17388 ServiceList.sort();
17389 ServiceList.unique();
17390 NumTrainsAtLoc = ServiceList.size();
17391 for(std::list<AnsiString>::iterator SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17393 Output = Output + *SLIt +
",";
17395 if(Output.Length() > 0)
17397 Output = Output.SubString(1, Output.Length() - 1);
17410 AnsiString(RepeatNum1) +
"," + AnsiString(RepeatNum2) +
"," + Location);
17412 std::list<AnsiString>::iterator LP1 = 0, LP2 = 0, ListPtr1 = 0, ListPtr2 = 0, LocPtr1 = 0, LocPtr2 = 0;
17417 bool LocFound =
false;
17418 AnsiString Ref1 = Ref1In, Ref2 = Ref2In;
17420 TDateTime FirstServiceTime;
17423 int Ref1Target = 0, Ref1Count = 0;
17424 int SlashPos = Ref1.Pos(
'/');
17427 Ref1Target = Ref1.SubString(SlashPos + 1, Ref1.Length() - SlashPos).ToInt();
17428 Ref1 = Ref1.SubString(1, SlashPos - 1);
17430 int Ref2Target = 0, Ref2Count = 0;
17431 SlashPos = Ref2.Pos(
'/');
17434 Ref2Target = Ref2.SubString(SlashPos + 1, Ref2.Length() - SlashPos).ToInt();
17435 Ref2 = Ref2.SubString(1, SlashPos - 1);
17437 for(ListPtr1 = List1.begin(); ListPtr1 != List1.end(); ListPtr1++)
17440 if((*ListPtr1) == Location)
17442 LocPtr1 = ListPtr1;
17445 if(ListPtr1->SubString(1, 3) ==
"%%%")
17447 AnsiString CDTTime = ListPtr1->SubString(4, 5);
17452 FirstServiceTime = TDateTime(-1);
17453 bool BreakFlag =
false;
17456 if(TDVIt->ServiceReference == Ref1)
17458 if(Ref1Target > Ref1Count)
17463 IncMinutes = TDVIt->ActionVector.back().RearStartOrRepeatMins;
17464 for(TActionVector::iterator AVIt = TDVIt->ActionVector.begin(); AVIt != TDVIt->ActionVector.end(); AVIt++)
17468 FirstServiceTime = AVIt->EventTime;
17474 FirstServiceTime = AVIt->ArrivalTime;
17480 FirstServiceTime = AVIt->DepartureTime;
17491 if(IncMinutes == -1)
17493 throw Exception(
"Failed to find service for ServiceRef1 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17495 if(FirstServiceTime == TDateTime(-1))
17497 throw Exception(
"Failed to find first service time for ServiceRef1 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17501 if(!Arrival && (Time1 == CDTTime))
17506 if(Arrival && (Time1 == CDTTime))
17510 if(Time1 > CDTTime)
17515 if(Time1 < CDTTime)
17528 for(ListPtr2 = List2.begin(); ListPtr2 != List2.end(); ListPtr2++)
17530 if((*ListPtr2) == Location)
17532 LocPtr2 = ListPtr2;
17535 if(ListPtr2->SubString(1, 3) ==
"%%%")
17537 AnsiString CDTTime = ListPtr2->SubString(4, 5);
17542 FirstServiceTime = TDateTime(-1);
17543 bool BreakFlag =
false;
17546 if(TDVIt->ServiceReference == Ref2)
17548 if(Ref2Target > Ref2Count)
17553 IncMinutes = TDVIt->ActionVector.back().RearStartOrRepeatMins;
17554 for(TActionVector::iterator AVIt = TDVIt->ActionVector.begin(); AVIt != TDVIt->ActionVector.end(); AVIt++)
17558 FirstServiceTime = AVIt->EventTime;
17564 FirstServiceTime = AVIt->ArrivalTime;
17570 FirstServiceTime = AVIt->DepartureTime;
17581 if(IncMinutes == -1)
17583 throw Exception(
"IncMinutes -1 for ServiceRef2 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17585 if(FirstServiceTime == TDateTime(-1))
17587 throw Exception(
"First service time -1 for ServiceRef2 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17591 if(!Arrival && (Time2 == CDTTime))
17596 if(Arrival && (Time2 == CDTTime))
17600 if(Time2 > CDTTime)
17605 if(Time2 < CDTTime)
17620 LP1 = List1.begin();
17622 for(ListPtr1 = LocPtr1; ListPtr1 != LP1; ListPtr1--)
17624 if(ListPtr1 == List1.begin())
17628 if(ListPtr1->SubString(1, 3) ==
"%%%")
17635 LP2 = List2.begin();
17637 for(ListPtr2 = LocPtr2; ListPtr2 != LP2; ListPtr2--)
17639 if(ListPtr2 == List2.begin())
17643 if(ListPtr2->SubString(1, 3) ==
"%%%")
17653 for(ListPtr1 = LP1; ListPtr1 != List1.end(); ListPtr1++)
17655 if(ListPtr1 == LocPtr1)
17659 if(ListPtr1->SubString(1, 3) ==
"%%%")
17663 for(ListPtr2 = LP2; ListPtr2 != List2.end(); ListPtr2++)
17665 if(ListPtr2 == LocPtr2)
17669 if(ListPtr2->SubString(1, 3) ==
"%%%")
17673 if((*ListPtr1) == (*ListPtr2))
17690 for(ListPtr1 = LP1; ListPtr1 != List1.end(); ListPtr1++)
17692 if(ListPtr1 == List1.end())
17696 if(ListPtr1->SubString(1, 3) ==
"%%%")
17700 for(ListPtr2 = LP2; ListPtr2 != List2.end(); ListPtr2++)
17702 if(ListPtr2 == List2.end())
17706 if(ListPtr2->SubString(1, 3) ==
"%%%")
17710 if((*ListPtr1) == (*ListPtr2))
17727 if(ExitList.empty())
17733 AnsiString ExitLocList =
"";
17736 unsigned int Counter = 0;
17741 if(((Counter % 6) == 0) && (Counter < (ExitList.size() - 1)))
17743 ExitLocList +=
"\n";
17746 if(StartName ==
"")
17748 if(ExitList.size() == 1)
17752 return(
" at " + ID);
17757 if(ExitList.size() < 4)
17759 AllowedExits =
",\nallowable exit element(s): " + ExitLocList;
17764 AllowedExits =
",\nallowable exit element(s):\n" + ExitLocList;
17774 if(ExitList.size() < 4)
17776 AllowedExits =
",\nallowable exit element(s): " + ExitLocList;
17781 AllowedExits =
",\nallowable exit element(s):\n" + ExitLocList;
17787 if(ExitList.size() < 4)
17789 AllowedExits =
",\nallowable exit element(s): " + ExitLocList;
17790 return(
" at " + StartName);
17794 AllowedExits =
",\nallowable exit element(s):\n" + ExitLocList;
17795 return(
" at " + StartName);
17835 AnsiString FormatStr =
"####0.0";
17836 AnsiString AvLateArrMins =
"";
17837 AnsiString AvEarlyArrMins =
"";
17838 AnsiString AvLatePassMins =
"";
17839 AnsiString AvEarlyPassMins =
"";
17840 AnsiString AvLateDepMins =
"";
17862 PerfFile <<
'\n' <<
'\n' <<
"***************************************";
17863 PerfFile <<
'\n' <<
'\n' <<
"Performance summary:" <<
'\n';
17875 PerfFile <<
LateArrivals <<
" late arrivals (average " << AvLateArrMins.c_str() <<
" min)" <<
'\n';
17879 PerfFile <<
LateArrivals <<
" late arrival (" << AvLateArrMins.c_str() <<
" min)" <<
'\n';
17887 PerfFile <<
EarlyArrivals <<
" early arrivals (average " << AvEarlyArrMins.c_str() <<
" min)" <<
'\n';
17891 PerfFile <<
EarlyArrivals <<
" early arrival (" << AvEarlyArrMins.c_str() <<
" min)" <<
'\n';
17899 PerfFile <<
OnTimePasses <<
" on-time passes" <<
'\n';
17907 PerfFile <<
LatePasses <<
" late passes (average " << AvLatePassMins.c_str() <<
" min)" <<
'\n';
17911 PerfFile <<
LatePasses <<
" late pass (" << AvLatePassMins.c_str() <<
" min)" <<
'\n';
17915 PerfFile <<
LatePasses <<
" late passes" <<
'\n';
17919 PerfFile <<
EarlyPasses <<
" early passes (average " << AvEarlyPassMins.c_str() <<
" min)" <<
'\n';
17923 PerfFile <<
EarlyPasses <<
" early pass (" << AvEarlyPassMins.c_str() <<
" min)" <<
'\n';
17927 PerfFile <<
EarlyPasses <<
" early passes" <<
'\n';
17931 PerfFile <<
OnTimeDeps <<
" on-time departures" <<
'\n';
17935 PerfFile <<
OnTimeDeps <<
" on-time departure" <<
'\n';
17939 PerfFile <<
LateDeps <<
" late departures (average " << AvLateDepMins.c_str() <<
" min)" <<
'\n';
17943 PerfFile <<
LateDeps <<
" late departure (" << AvLateDepMins.c_str() <<
" min)" <<
'\n';
17947 PerfFile <<
LateDeps <<
" late departures" <<
'\n';
17949 TDateTime TempExcessLCDownTime;
17963 if(TempExcessLCDownTime > TDateTime(0))
17969 AnsiString FormattedExcessLCDownMins = FormatFloat(FormatStr,
ExcessLCDownMins);
17973 PerfFile << FormattedExcessLCDownMins.c_str() <<
" excess minutes of level crossing barrier down time" <<
'\n';
17977 PerfFile <<
MissedStops <<
" missed stops" <<
'\n';
17981 PerfFile <<
MissedStops <<
" missed stop" <<
'\n';
18009 PerfFile <<
NumFailures <<
" train failures" <<
'\n';
18013 PerfFile <<
NumFailures <<
" train failure" <<
'\n';
18019 PerfFile <<
AvHoursIntValue <<
" hour mean time betweeen train failures" <<
'\n';
18023 PerfFile <<
AvHoursIntValue <<
" hours mean time betweeen train failures" <<
'\n';
18026 AnsiString AvLateMinsLocsNotReached =
"";
18032 if(LocsNotReached > 0)
18035 PerfFile << LocsNotReached <<
" locations that trains failed to reach (average lateness " << AvLateMinsLocsNotReached.c_str() <<
" min)" <<
'\n';
18039 PerfFile <<
SPADRisks <<
" SPAD risks" <<
'\n';
18043 PerfFile <<
SPADRisks <<
" SPAD risk" <<
'\n';
18055 PerfFile <<
Derailments <<
" derailments" <<
'\n';
18059 PerfFile <<
Derailments <<
" derailment" <<
'\n';
18069 PerfFile <<
'\n' <<
"***************************************" <<
'\n';
18071 bool DerailSPADFlag =
false, CrashFlag =
false;
18073 int OverallScorePercent = 100;
18075 double TotLateMinsFactor = 1;
18076 double MissedStopAndSPADRiskFactor = 1;
18077 double NetNegFactor = 1;
18086 OverallScorePercent = 5;
18087 DerailSPADFlag =
true;
18091 OverallScorePercent = 0;
18094 if(OverallScorePercent == 100)
18098 TotLateMinsFactor =
18106 NetNegFactor = TotLateMinsFactor * MissedStopAndSPADRiskFactor;
18108 OverallScorePercent = 100 * NetNegFactor;
18111 if((TotArrDep > 0) || DerailSPADFlag || CrashFlag)
18114 AnsiString OneFailureString =
", though the failure would account for some poor performance";
18115 AnsiString TwoOrMoreFailureString =
", though the failures would account for some poor performance";
18116 AnsiString AddedString =
"";
18119 AddedString = OneFailureString;
18123 AddedString = TwoOrMoreFailureString;
18125 PerfFile <<
"\nOverall score: " << OverallScorePercent <<
"%\n";
18126 AnsiString Rating =
"";
18127 if(OverallScorePercent == 100)
18129 Rating =
"Perfect!";
18131 else if(OverallScorePercent >= 95)
18133 Rating =
"Excellent";
18135 else if(OverallScorePercent >= 90)
18137 Rating =
"Very good";
18139 else if(OverallScorePercent >= 80)
18143 else if(OverallScorePercent >= 70)
18147 else if(OverallScorePercent >= 60)
18149 Rating =
"Unacceptable" + AddedString;
18151 else if(OverallScorePercent >= 50)
18153 Rating =
"Poor" + AddedString;
18155 else if(OverallScorePercent >= 40)
18157 Rating =
"Bad" + AddedString;
18159 else if(OverallScorePercent >= 30)
18161 Rating =
"Very bad" + AddedString;
18163 else if(OverallScorePercent >= 20)
18165 Rating =
"Terrible" + AddedString;
18167 else if(OverallScorePercent >= 10)
18169 Rating =
"Appalling" + AddedString;
18171 else if(OverallScorePercent >= 5)
18175 Rating =
"Disastrous - potential loss of life";
18180 Rating =
"Dire" + AddedString;
18183 else if(OverallScorePercent < 5)
18187 Rating =
"Catastrophic - loss of life";
18191 Rating =
"Abysmal";
18194 PerfFile <<
"Overall rating: " << Rating.c_str() <<
'\n';
18198 PerfFile <<
"\nThere were no timetabled departures or arrivals so there is insufficient information to provide a performance score or rating" <<
'\n';
18200 PerfFile <<
'\n' <<
"***************************************";
18209 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
18259 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
18294 int IncrementalMinutes = 0;
18308 bool TrainOperatingFlag =
false;
18313 TrainOperatingFlag =
true;
18317 if(TrainOperatingFlag)
18325 for(
unsigned int z = 0; z < TDEntry.
ActionVector.size(); z++)
18372 AnsiString HeadCode;
18376 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
18380 HCandTrainPosParam.first = HeadCode;
18381 HCandTrainPosParam.second = TrainID;
18383 if((TimeToAct >= 0) && (TimeToAct < 59.9))
18386 OpTimeToActMultiMapEntry.first = TimeToAct;
18387 OpTimeToActMultiMapEntry.second = HCandTrainPosParam;
18416 float TimeToAct = 0;
18417 int DistanceToRedSignal = 0;
18420 ContinuationEntryVecPosVector.clear();
18421 bool LaterTrain =
false;
18425 LaterTrain =
false;
18426 if(CTEIt->second.TrainDataEntryPtr->TrainOperatingDataVector.at(CTEIt->second.RepeatNumber).RunningEntry !=
NotStarted)
18437 if(!ContinuationEntryVecPosVector.empty())
18439 for(
unsigned int x = 0; x < ContinuationEntryVecPosVector.size(); x++)
18441 if(CTEIt->second.VectorPosition == ContinuationEntryVecPosVector.at(x))
18455 ContinuationEntryVecPosVector.push_back(CTEIt->second.VectorPosition);
18456 AnsiString HeadCode = CTEIt->second.HeadCode;
18457 float CurrentStopTime;
18458 float LaterStopTime;
18459 float RecoverableTime;
18462 bool SigControlAndCanPassRedSignal =
false;
18466 SigControlAndCanPassRedSignal, &CTEIt->second.TrainDataEntryPtr->ActionVector.at(1),
18468 HeadCode, TrainID, CurrentStopTime, LaterStopTime, RecoverableTime, AvTrackSpeed);
18471 if(AvTrackSpeed < 30)
18475 if(DistanceToRedSignal == -1)
18481 int Speed = AvTrackSpeed;
18482 int MaxSpeed = int(CTEIt->second.TrainDataEntryPtr->MaxRunningSpeed);
18483 if(AvTrackSpeed > MaxSpeed)
18487 if(CTEIt->second.TrainDataEntryPtr->ActionVector.at(1).SignallerControl)
18490 Speed = CTEIt->second.TrainDataEntryPtr->SignallerSpeed;
18493 TimeToAct = LaterStopTime + DistanceToRedSignal * 3.6 / 60 / Speed;
18498 float MinsBefEnter = double(CTEIt->first -
TTClockTime) * 86400.0 / 60.0;
18499 TimeToAct += MinsBefEnter;
18502 HCandTrainPosParam.first = HeadCode;
18503 HCandTrainPosParam.second = -1 - CTEIt->second.VectorPosition;
18506 if(TimeToAct < 59.9)
18508 OpTimeToActMultiMapEntry.first = TimeToAct;
18509 OpTimeToActMultiMapEntry.second = HCandTrainPosParam;
18521 bool SigControlAndCanPassRedSignal,
TActionVectorEntry *AVPtr, AnsiString HeadCode,
int TrainID,
float &CurrentStopTime,
float &LaterStopTime,
18522 float &RecoverableTime,
int &AvTrackSpeed)
18531 AnsiString(TrackVectorPositionEntryPos) +
", " + AVPtr->
Command);
18532 int DistanceToRedSignal = 0;
18533 int CumTrackSpeed = 0;
18535 int TrackSpeedCount = 0;
18545 int CurrentElement = TrackVectorPosition;
18546 int CurrentEntryPos = TrackVectorPositionEntryPos;
18551 CurrentStopTime = 0;
18553 RecoverableTime = 0;
18554 if(CurrentElement == -1)
18559 int CurrentExitPos;
18564 if((CurrentEntryPos == 0) || (CurrentEntryPos == 2))
18568 CurrentExitPos = 1;
18572 CurrentExitPos = 3;
18577 CurrentExitPos = 0;
18613 CurrentStopTime = float(TimeToDepart);
18619 if((CurrentExitConfig ==
Signal) && (CurrentAttribute == 0))
18630 else if(SigControlAndCanPassRedSignal)
18635 if((NextEntryPos == 0) || (NextEntryPos == 2))
18656 CurrentElement = NextElement;
18657 CurrentEntryPos = NextEntryPos;
18658 CurrentExitPos = NextExitPos;
18670 int LaterStopNumber = 0;
18674 while(!((CurrentExitConfig ==
Signal) && (CurrentAttribute == 0)))
18683 if(CurrentEntryPos > 1)
18703 bool StopRequired =
false;
18720 int TrainOnElement;
18727 if(CurrentEntryPos > 1)
18736 if((TrainOnElement > -1) && (TrainOnElement != TrainID))
18745 double StopTimeDouble;
18758 if(StopTimeDouble < 0.5)
18760 StopTimeDouble = 0.5;
18764 LaterStopTime += float(StopTimeDouble);
18765 RecoverableTime += StopTimeDouble - 0.5;
18766 if((LaterStopNumber == 1) && (TrainID > -1))
18774 if((AVPtr + 1)->FormatType ==
TimeLoc)
18778 StopTimeDouble = double((AVPtr + 1)->DepartureTime - AVPtr->
ArrivalTime) * 86400.0 / 60.0;
18780 if(StopTimeDouble < 0.5)
18782 StopTimeDouble = 0.5;
18785 LaterStopTime += float(StopTimeDouble);
18786 RecoverableTime += StopTimeDouble - 0.5;
18787 if((LaterStopNumber == 1) && (TrainID > -1))
18803 if(NextElement == -1)
18812 if((NextEntryPos == 0) || (NextEntryPos == 2))
18833 CurrentElement = NextElement;
18834 CurrentEntryPos = NextEntryPos;
18835 CurrentExitPos = NextExitPos;
18839 if((CurrentExitConfig ==
Signal) && (CurrentAttribute == 0))
18854 float MaxAllowableSpeed;
18856 if(TrackSpeedCount > 0)
18858 MaxAllowableSpeed = CumTrackSpeed / TrackSpeedCount;
18862 if(CurrentEntryPos > 1)
18872 float KmPerLocationStop;
18874 if(LaterStopNumber > 0)
18876 KmPerLocationStop = float(DistanceToRedSignal) / LaterStopNumber / 1000;
18877 AvTrackSpeed = (8.75 * KmPerLocationStop) + 44;
18881 AvTrackSpeed = (sqrt(
float(DistanceToRedSignal) / 1000) * 44) + 60;
18885 if(AvTrackSpeed > MaxAllowableSpeed)
18887 AvTrackSpeed = MaxAllowableSpeed;
18890 return(DistanceToRedSignal);